#include <bits/stdc++.h>
using namespace std;
const int maxa = 1000006;
char str[maxa][10];
int maxn[maxa], mina[maxa];
int o[maxa];
int ans[maxa];
int main() {
  int n;
  scanf("%d", &n);
  int jinwei[10];
  jinwei[0] = 1;
  for (int i = 1; i < 10; i++) {
    jinwei[i] = jinwei[i - 1] * 10;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", &str[i]);
    o[i] = strlen(str[i]);
    for (int k = 0; k < o[i] / 2; k++) {
      swap(str[i][k], str[i][o[i] - 1 - k]);
    }
    for (int k = 0; k < o[i]; k++) {
      if (str[i][k] != '?')
        maxn[i] += jinwei[k] * (str[i][k] - '0'),
            mina[i] += jinwei[k] * (str[i][k] - '0');
      else {
        maxn[i] += jinwei[k] * 9;
        if (k == o[i] - 1) mina[i] += jinwei[k];
      }
    }
  }
  int ok = 1;
  ans[0] = mina[0];
  for (int i = 1; i < n; i++) {
    if (maxn[i] <= ans[i - 1]) {
      ok = 0;
      break;
    }
    if (mina[i] > ans[i - 1]) {
      ans[i] = mina[i];
    }
    for (int k = o[i] - 1; k >= 0; k--) {
      if (str[i][k] == '?') {
        for (int j = k == (o[i] - 1) ? 2 : 1; j <= 9; j++) {
          if (maxn[i] - jinwei[k] > ans[i - 1])
            maxn[i] -= jinwei[k];
          else
            break;
        }
      }
    }
    ans[i] = maxn[i];
  }
  if (ok == 0) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      printf("%d\n", ans[i]);
    }
  }
}
