#include <bits/stdc++.h>
using namespace std;
int n, flag, ln, prv = -1;
char in[100010][20], pr[100010][20];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", in[i]);
    ln = strlen(in[i]);
    flag = 0;
    if (ln < prv) {
      printf("NO\n");
      return 0;
    } else if (i == 0 || ln > prv) {
      for (int j = 0; j < ln; j++) {
        if (j == 0 && in[i][j] == '?')
          pr[i][j] = '1';
        else if (in[i][j] == '?')
          pr[i][j] = '0';
        else
          pr[i][j] = in[i][j];
      }
    } else {
      for (int j = 0; j < ln; j++) {
        if (in[i][j] == '?') {
          if (flag == 0)
            pr[i][j] = pr[i - 1][j];
          else
            pr[i][j] = '0';
        } else if (in[i][j] > pr[i - 1][j]) {
          pr[i][j] = in[i][j];
          flag = 1;
        } else if (in[i][j] < pr[i - 1][j] && flag == 0) {
          for (int x = j - 1; x >= 0; x--) {
            if (in[i][x] == '?' && pr[i][x] < '9') {
              pr[i][x]++;
              for (int z = x + 1; z < j; z++)
                if (in[i][z] == '?') pr[i][z] = '0';
              flag = 1;
              break;
            }
          }
          if (flag == 0) {
            printf("NO\n");
            return 0;
          }
          pr[i][j] = in[i][j];
        } else
          pr[i][j] = in[i][j];
      }
      if (flag == 0) {
        for (int j = ln - 1; j >= 0; j--) {
          if (in[i][j] == '?' && pr[i][j] < '9') {
            pr[i][j]++;
            for (int z = j + 1; z < ln; z++)
              if (in[i][z] == '?') pr[i][z] = '0';
            flag = 1;
            break;
          }
        }
        if (flag == 0) {
          printf("NO\n");
          return 0;
        }
      }
    }
    prv = ln;
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) printf("%s\n", pr[i]);
  return 0;
}
