#include <bits/stdc++.h>
using namespace std;
struct __s {
  __s() {
    if (1) {
      ios_base::Init i;
      cin.sync_with_stdio(0);
      cin.tie(0);
    }
  }
  ~__s() {
    if (!1)
      fprintf(stderr, "Execution time: %.3lf s.\n",
              (double)clock() / CLOCKS_PER_SEC);
    long long n;
    cin >> n;
  }
} __S;
long long n;
string s1, s2;
vector<string> ans;
long long rec(long long i, long long j) {
  while (i < s1.size() && s1[i] == s2[i]) i++;
  if (i == s1.size()) return 2;
  if (s2[i] == '?') {
    long long res = rec(i + 1, j + 1);
    if (res != 1) {
      if (s1[i] == '9') {
        if (j == 0) {
          cout << "NO" << '\n';
          exit(0);
        }
        s2[i] = '0';
        return 0;
      } else {
        s2[i] = s1[i] + 1;
        return 1;
      }
    } else {
      s2[i] = s1[i];
      return 1;
    }
  } else
    return (s2[i] > s1[i]);
}
int main(void) {
  cin >> n >> s1;
  if (s1[0] == '?') s1[0] = '1';
  for (long long i = 0; i < (long long)(s1.size()); i++) {
    if (s1[i] == '?') s1[i] = '0';
  }
  ans.push_back(s1);
  for (long long i = 0; i < (long long)(n - 1); i++) {
    cin >> s2;
    if (s2.size() < s1.size()) return cout << "NO" << '\n', 0;
    if (s2.size() > s1.size()) {
      if (s2[0] == '?') s2[0] = '1';
      for (long long j = 0; j < (long long)(s2.size()); j++) {
        if (s2[j] == '?') s2[j] = '0';
      }
    } else {
      if (rec(0, 0) != 1) return cout << "NO" << '\n', 0;
      for (long long j = 0; j < (long long)(s2.size()); j++) {
        if (s2[j] == '?') s2[j] = '0';
      }
    }
    s1 = s2;
    ans.push_back(s1);
  }
  cout << "YES" << '\n';
  for (long long i = 0; i < (long long)(ans.size()); i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
