#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n;
char str[maxn][10], t[10];
int len[maxn];
int main() {
  scanf("%d", &n);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str[i]);
    len[i] = strlen(str[i]);
    if (len[i] < len[i - 1]) flag = 1;
  }
  if (flag) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < len[1]; i++) {
    if (str[1][i] == '?') {
      if (i == 0)
        str[1][i] = '1';
      else
        str[1][i] = '0';
    }
  }
  for (int i = 2; i <= n; i++) {
    strcpy(t, str[i]);
    for (int j = 0; j < len[i]; j++)
      if (t[j] == '?') t[j] = '9';
    if (strcmp(t, str[i - 1]) < 1 && len[i] <= len[i - 1]) {
      puts("NO");
      return 0;
    }
    for (int j = 0; j < len[i]; j++)
      if (str[i][j] == '?') {
        int k = 1;
        if (j != 0) k = 0;
        for (; k <= 9; k++) {
          t[j] = k + '0';
          if (strcmp(t, str[i - 1]) == 1 || len[i] > len[i - 1]) break;
        }
      }
    strcpy(str[i], t);
    if (len[i] < len[i - 1]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) puts(str[i]);
  return 0;
}
