#include <bits/stdc++.h>
using namespace std;
char c[100005][9];
int main() {
  int i, j, n, m, f, x1, x2, p, ff, q;
  f = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%s", c[i]);
  }
  m = strlen(c[1]);
  for (i = 0; i < m; i++) {
    if (i == 0 && c[1][i] == '?')
      c[1][i] = '1';
    else if (c[1][i] == '?')
      c[1][i] = '0';
  }
  for (i = 2; i <= n; i++) {
    x1 = strlen(c[i - 1]);
    x2 = strlen(c[i]);
    if (x1 > x2) {
      f = 1;
      break;
    }
    if (x1 < x2) {
      for (j = 0; j < x2; j++) {
        if (c[i][j] == '?') {
          if (j == 0)
            c[i][j] = '1';
          else
            c[i][j] = '0';
        }
      }
      continue;
    }
    p = 0;
    for (j = 0; j < x2; j++) {
      if (c[i][j] == '?') {
        if (p) {
          c[i][j] = '0';
          continue;
        }
        ff = 0;
        for (q = j + 1; q < x2; q++) {
          if (c[i][q] != '?') {
            if (c[i][q] < c[i - 1][q]) {
              ff = 1;
              break;
            } else if (q == x2 - 1 && c[i][q] == c[i - 1][q]) {
              ff = 1;
              break;
            }
            if (c[i][q] > c[i - 1][q]) break;
          } else {
            if (c[i - 1][q] == '9' && q == x2 - 1) {
              ff = 1;
              break;
            }
            if (c[i - 1][q] < '9') {
              break;
            }
          }
        }
        if (j == x2 - 1) ff = 1;
        if (ff && c[i - 1][j] == '9') {
          f = 1;
          break;
        } else if (ff) {
          c[i][j] = c[i - 1][j] + 1;
          p = 1;
        } else {
          c[i][j] = c[i - 1][j];
        }
      } else {
        if (p) continue;
        if (c[i][j] < c[i - 1][j]) {
          f = 1;
          break;
        }
        if (c[i][j] > c[i - 1][j]) {
          p = 1;
        }
      }
    }
    if (strcmp(c[i - 1], c[i]) >= 0) {
      f = 1;
      break;
    }
    if (f) break;
  }
  if (f)
    printf("NO\n");
  else {
    printf("YES\n");
    for (i = 1; i <= n; i++) printf("%s\n", c[i]);
  }
}
