#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return b / gcd(a, b) * a; }
int n;
char g[100001][10];
char v[100001][10];
int len[100001];
int mx;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", g[i]);
    len[i] = strlen(g[i]);
    if (len[i] < mx) {
      puts("NO");
      return 0;
    }
    mx = len[i];
  }
  bool rr = 0;
  for (int(i) = 0; i < int(len[1]); ++i) {
    v[1][i] = g[1][i];
    if (v[1][i] == '?') v[1][i] = '0' + !rr;
    rr = 1;
  }
  for (int i = 2; i <= n; ++i) {
    if (len[i] != len[i - 1]) {
      bool r = 0;
      for (int j = 0; j < len[i]; ++j) {
        v[i][j] = g[i][j];
        if (g[i][j] == '?') v[i][j] = '0' + !r;
        r = 1;
      }
    } else {
      for (int j = 0; j < len[i]; ++j) {
        if (g[i][j] != '?')
          v[i][j] = g[i][j];
        else
          v[i][j] = v[i - 1][j];
      }
      bool can = 0;
      int idx = 10;
      int eq = 0;
      int last = -1;
      bool flag = 0;
      for (int j = 0; j < len[i]; ++j) {
        if (v[i - 1][j] > v[i][j]) {
          if (!can && !flag) {
            puts("NO");
            return 0;
          }
          idx = min(idx, j);
        }
        if (v[i][j] < '9' && g[i][j] == '?') can = 1;
        if (v[i][j] > v[i - 1][j]) flag = 1;
        eq += v[i][j] == v[i - 1][j];
        if (g[i][j] == '?' && v[i - 1][j] != '9') last = max(last, j);
      }
      if (eq == len[i]) {
        if (last == -1) {
          puts("NO");
          return 0;
        }
        ++v[i][last];
        for (int j = last + 1; j < len[i]; ++j)
          if (g[i][j] == '?') v[i][j] = '0';
      } else {
        for (int j = 0; j < len[i]; ++j) {
          if (v[i][j] > v[i - 1][j]) {
            for (int k = j + 1; k < len[i]; ++k)
              if (g[i][k] == '?') v[i][k] = '0';
            break;
          }
          if (v[i][j] < v[i - 1][j]) {
            int idx = -1;
            for (int k = j - 1; k >= 0; --k) {
              if (g[i][k] == '?' && v[i][k] != '9') {
                idx = k;
                break;
              }
            }
            if (idx == -1) {
              puts("NO");
              return 0;
            }
            ++v[i][idx];
            for (int k = idx + 1; k < len[i]; ++k) {
              if (g[i][k] == '?') v[i][k] = '0';
            }
            break;
          }
        }
      }
    }
  }
  puts("YES");
  for (int i = 1; i <= n; ++i) puts(v[i]);
  cin >> n;
}
