#include <bits/stdc++.h>
using namespace std;
int n, m, prelen, f[10][2], kq[100010], lc;
char s[10], pre[10];
void dp(int vt, bool ok) {
  if (f[vt][ok] != -1) return;
  f[vt][ok] = 1;
  if (vt > m - 1) {
    if (ok == false) {
      int num = 0;
      for (int i = 0; i <= m - 1; ++i) {
        num = num * 10 + (s[i] - '0');
        pre[i] = s[i];
      }
      ++kq[0];
      kq[kq[0]] = num;
      prelen = m;
      lc = 1;
    }
    return;
  }
  if (s[vt] != '?') {
    if (ok) {
      if (s[vt] < pre[vt]) return;
      if (s[vt] == pre[vt]) {
        dp(vt + 1, ok);
        if (lc == 1) return;
      }
      if (s[vt] > pre[vt]) {
        dp(vt + 1, !ok);
        if (lc == 1) return;
      }
    } else {
      dp(vt + 1, ok);
      if (lc == 1) return;
    }
  } else {
    int cmin = 0;
    if (ok) cmin = pre[vt] - '0';
    if (vt == 0) cmin = max(cmin, 1);
    for (int i = cmin; i <= 9; ++i) {
      if (ok) {
        if (char(i + 48) == pre[vt]) {
          s[vt] = char(i + 48);
          dp(vt + 1, ok);
          if (lc == 1) return;
        } else {
          s[vt] = char(i + 48);
          dp(vt + 1, !ok);
          if (lc == 1) return;
        }
      } else {
        s[vt] = char(i + 48);
        dp(vt + 1, ok);
        if (lc == 1) return;
      }
      s[vt] = '?';
    }
  }
}
int main() {
  scanf("%d\n", &n);
  pre[0] = '0';
  prelen = 1;
  for (int i = 1; i <= n; ++i) {
    gets(s);
    m = strlen(s);
    lc = 0;
    if (m >= prelen) {
      for (int j = m - prelen; j <= m - 1; ++j) pre[j] = pre[j - m + prelen];
      for (int j = 0; j <= m - prelen - 1; ++j) pre[j] = 0;
      for (int j = 0; j <= 9; ++j)
        for (int k = 0; k <= 1; ++k) f[j][k] = -1;
      dp(0, true);
    }
    if (lc == 0) {
      printf("NO");
      exit(0);
    }
  }
  printf("YES\n");
  for (int i = 1; i <= kq[0]; ++i) printf("%d\n", kq[i]);
  fclose(stdin);
  fclose(stdout);
}
