#include <bits/stdc++.h>
using namespace std;
int getmax(char* s) {
  int l = strlen(s), ans = 0;
  for (int i = 0; i < l; i++)
    if (s[i] != '?')
      ans = ans * 10 + s[i] - 48;
    else
      ans = ans * 10 + 9;
  return ans;
}
int a[100005];
char s[10];
int main() {
  int n;
  int last = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    int l = strlen(s);
    if (getmax(s) <= last) {
      puts("NO");
      return 0;
    }
    for (int k = 0; k < l; k++) {
      if (s[k] == '?') {
        for (int j = 0; j < 10; j++) {
          if (k == 0 && j == 0) continue;
          s[k] = j + 48;
          if (getmax(s) > last) break;
        }
      }
    }
    a[i] = getmax(s);
    last = a[i];
  }
  puts("YES");
  for (int i = 0; i < n; i++) cout << a[i] << endl;
  return 0;
}
