#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 233333;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
int n;
char s[N][10];
bool work(int i, int j, int x) {
  bool ret = true;
  if (strlen(s[i]) > strlen(s[i - 1])) return true;
  int len = strlen(s[i]);
  for (int k = 0; k < (len); ++k) {
    int a = s[i][k], b = s[i - 1][k];
    if (s[i][k] == '?') a = '9';
    if (k == j) a = '0' + x;
    if (a < b) return false;
    if (a > b) return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%s", s[i]);
  }
  bool ok = true;
  for (int i = 0; i < (n); ++i) {
    if (!i) continue;
    if (strlen(s[i]) < strlen(s[i - 1])) ok = false;
  }
  if (s[0][0] == '?') {
    if (strlen(s[0]) == 1)
      s[0][0] = '1';
    else
      s[0][0] = '1';
  }
  for (int i = 1; s[0][i] != '\0'; i++) {
    if (s[0][i] == '?') s[0][i] = '0';
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; s[i][j] != '\0'; j++) {
      if (s[i][j] != '?') continue;
      int l = 0, r = 9, mid;
      if (j == 0) l = 1;
      l--;
      while (l + 1 < r) {
        mid = (l + r) / 2;
        if (work(i, j, mid))
          r = mid;
        else
          l = mid;
      }
      if (work(i, j, r))
        s[i][j] = '0' + r;
      else
        ok = false;
    }
    if (!work(i, 10, 0)) ok = false;
  }
  if (!ok)
    puts("NO");
  else {
    puts("YES");
    for (int i = 0; i < (n); ++i) {
      printf("%s\n", s[i]);
    }
  }
  return 0;
}
