#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
char s[maxn][11];
int ans[maxn];
void cha(int a) {
  ans[a] = 0;
  for (int i = 0; s[a][i]; i++) {
    ans[a] *= 10;
    ans[a] += s[a][i] - '0';
  }
}
bool sol(int a) {
  int n1 = strlen(s[a - 1]), n2 = strlen(s[a]);
  if (n1 > n2) {
    return 0;
  }
  if (n1 < n2) {
    for (int i = 0; i < n2; i++) {
      if (s[a][i] == '?') {
        if (i)
          s[a][i] = '0';
        else
          s[a][i] = '1';
      }
    }
    return 1;
  }
  bool xing = 0;
  int wei = 0;
  int arr[10];
  for (int i = 0; i < n1; i++) {
    if (xing) {
      if (s[a][i] == '?') s[a][i] = '0';
    } else {
      if (s[a][i] == '?') {
        arr[wei++] = i;
        s[a][i] = s[a - 1][i];
      } else if (s[a][i] < s[a - 1][i]) {
        for (int i = wei - 1; i > -1; i--) {
          if (s[a][arr[i]] != '9') {
            xing = 1;
            s[a][arr[i]]++;
            for (int j = i + 1; j < wei; j++) {
              s[a][arr[j]] = '0';
            }
            break;
          }
        }
        if (!xing) return 0;
      } else if (s[a][i] > s[a - 1][i]) {
        xing = 1;
      }
    }
  }
  if (!xing) {
    for (int i = wei - 1; i > -1; i--) {
      if (s[a][arr[i]] != '9') {
        xing = 1;
        s[a][arr[i]]++;
        for (int j = i + 1; j < wei; j++) {
          s[a][arr[j]] = '0';
        }
        break;
      }
    }
    if (!xing) return 0;
  }
  return 1;
}
int main() {
  int a, b, c, d, e, f, g, h;
  ios::sync_with_stdio(0);
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> s[i];
  }
  for (int i = 0; s[0][i]; i++) {
    if (s[0][i] == '?') {
      if (i)
        s[0][i] = '0';
      else
        s[0][i] = '1';
    }
  }
  cha(0);
  for (int i = 1; i < a; i++) {
    if (!sol(i)) {
      cout << "NO" << endl;
      return 0;
    }
    cha(i);
  }
  cout << "YES" << endl;
  for (int i = 0; i < a; i++) {
    cout << ans[i] << endl;
  }
}
