#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;
int n;
string a[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[0] = "0";
  for (int i = 1; i <= n; i++) {
    string s = a[i], t = a[i - 1];
    if (s.length() < t.length()) {
      return cout << "NO", 0;
      ;
    }
    if (s.length() > t.length()) {
      for (int j = 0; j < s.length(); j++) {
        if (s[j] == '?') {
          if (j == 0)
            a[i][j] = '1';
          else
            a[i][j] = '0';
        }
      }
      continue;
    }
    string pres = "", pret = "", ns;
    bool ck = 1;
    for (int j = 0; j < s.length(); j++) {
      pres += s[j];
      pret += t[j];
      if (s[j] == '?') {
        pres[j] = (char)min(t[j] + 1, (int)'9');
      }
      if (pres > pret) {
        ck = 0;
        ns = pres;
        for (int k = j + 1; k < s.length(); k++) {
          if (s[k] == '?')
            ns += '0';
          else
            ns += s[k];
        }
        a[i] = min(a[i], ns);
      }
      if (s[j] == '?') pres[j] = pret[j];
    }
    if (ck) return cout << "NO", 0;
    ;
  }
  cout << "YES" << '\n';
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
}
