#include <bits/stdc++.h>
using namespace std;
bool eq(string s1, string s2, int l, int len) {
  if (l < 0) return true;
  int i, j, k;
  if (s1[l] == s2[l]) return true;
  if (s1[l] == '?')
    return true;
  else
    return false;
}
string smaller(string s1, int l, int len) {
  string cur;
  cur = "";
  int i;
  for (i = l; i < len; i++) {
    if (s1[i] == '?')
      cur += "0";
    else
      cur += s1[i];
  }
  return cur;
}
int main() {
  int i, j, k, n;
  cin >> n;
  string s[n + 1];
  for (i = 0; i < n; i++) cin >> s[i + 1];
  s[0] = "0";
  for (i = 1; i <= n; i++) {
    if (s[i].length() > s[i - 1].length()) {
      if (s[i][0] == '?') {
        s[i][0] = '1';
      }
      for (j = 1; j < s[i].length(); j++) {
        if (s[i][j] == '?') {
          s[i][j] = '0';
        }
      }
    } else if (s[i].length() < s[i - 1].length()) {
      cout << "NO";
      return 0;
    } else {
      set<string> comp;
      string temp, cur, lc;
      cur = "";
      for (j = 0; j < s[i].length(); j++) {
        if (eq(s[i], s[i - 1], j - 1, s[i].length())) {
          if ((s[i][j] > s[i - 1][j] && s[i][j] != '?') ||
              (s[i][j] == '?' && s[i - 1][j] != '9')) {
            if (s[i][j] != '?') {
              lc = s[i][j];
              temp = cur + lc + smaller(s[i], j + 1, s[i].length());
            } else {
              lc = s[i - 1][j];
              lc[0] += 1;
              temp = cur + lc + smaller(s[i], j + 1, s[i].length());
            }
            comp.insert(temp);
          }
        } else {
          break;
        }
        cur += s[i - 1][j];
      }
      if (comp.size() == 0) {
        cout << "NO";
        return 0;
      }
      s[i] = *comp.begin();
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < n; i++) {
    cout << s[i + 1] << endl;
  }
  return 0;
}
