#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
inline void read(int &x) {
  char ch;
  x = 0;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; x = x * 10 + ch - 48, ch = getchar())
    ;
}
char str[N][10];
int a[N], b[N];
int main() {
  int i, j, t, s, n, l, r, k, ans;
  int x, y, f;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) scanf("%s", str[i]);
    l = strlen(str[0]);
    if (str[0][0] == '?') str[0][0] = '1';
    for (j = 1; j < l; j++)
      if (str[0][j] == '?') str[0][j] = '0';
    for (i = 1; i < n; i++) {
      l = strlen(str[i - 1]), r = strlen(str[i]);
      if (l > r) break;
      if (r > l) {
        if (str[i][0] == '?') str[i][0] = '1';
        for (j = 1; j < r; j++)
          if (str[i][j] == '?') str[i][j] = '0';
        continue;
      }
      for (t = f = j = 0; j < l; j++) {
        if (str[i][j] != '?') {
          if (str[i][j] > str[i - 1][j])
            break;
          else if (str[i][j] < str[i - 1][j]) {
            if (t) {
              f = 1;
              break;
            } else
              goto out;
          }
        } else
          t = 1;
      }
      if (!f && j < l) {
        for (k = 0; k < j; k++)
          if (str[i][k] == '?') str[i][k] = str[i - 1][k];
        for (k = j; k < l; k++)
          if (str[i][k] == '?') str[i][k] = '0';
      } else {
        for (j = 0; j < l; j++)
          if (str[i][j] != '?' && str[i][j] < str[i - 1][j]) break;
        for (k = j - 1; k >= 0; k--)
          if (str[i][k] == '?' && str[i - 1][k] != '9') break;
        if (k >= 0) {
          str[i][k] = str[i - 1][k] + 1;
          for (j = 0; j < k; j++) str[i][j] = str[i - 1][j];
          for (j = k + 1; j < l; j++)
            if (str[i][j] == '?') str[i][j] = '0';
        } else
          goto out;
      }
    }
  out:
    if (i < n)
      printf("NO\n");
    else {
      printf("YES\n");
      for (i = 0; i < n; i++) printf("%s\n", str[i]);
    }
  }
}
