#include <bits/stdc++.h>
using namespace std;
int a[100005];
char s[100005][8];
char tmp[8];
int main() {
  ios::sync_with_stdio(false);
  int i, j, n;
  string t;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> t;
    for (j = 0; j < 8 - t.size(); j++) s[i][j] = '0';
    j = 0;
    while (j < t.size()) {
      s[i][j + 8 - t.size()] = t[j];
      j++;
    }
  }
  for (j = 0; j < 8; j++) s[0][j] = '0';
  int last;
  for (i = 1; i <= n; i++) {
    last = -1;
    for (j = 0; j < 8; j++) tmp[j] = s[i][j];
    for (j = 0; j < 8; j++)
      if (s[i][j] != '0') break;
    if (s[i][j] == '?' && s[i - 1][j] == '0') {
      s[i][j] = '1';
    } else
      for (j = 0; j < 8; j++) {
        if (s[i][j] != '?' && s[i][j] > s[i - 1][j]) break;
        if (s[i][j] == '?') {
          s[i][j] = s[i - 1][j];
          if (s[i][j] != '9') last = j;
        }
        if (s[i][j] < s[i - 1][j] && last != -1 ||
            j == 7 && s[i][j] == s[i - 1][j] && last != -1) {
          s[i][last] = char(s[i][last] + 1);
          j = 8;
          while (++last < 8)
            if (tmp[last] == '?') s[i][last] = '0';
        }
      }
    while (++j < 8) {
      if (s[i][j] == '?') s[i][j] = '0';
    }
    for (j = 0; j < 8; j++) {
      a[i] *= 10;
      a[i] = a[i] + s[i][j] - '0';
    }
    if (a[i] <= a[i - 1]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl;
  for (i = 1; i <= n; i++) cout << a[i] << endl;
  ;
  return 0;
}
