#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 3;
string s[MAXN];
int start_pos[MAXN];
string our, their, buf;
int our_start;
int max_len;
int DP[9][2];
inline bool is_all_qns(string x) {
  for (int i = 0; i < (int)(x.length()); i++) {
    if (x[i] != '?') {
      return false;
    }
  }
  return true;
}
int dp(int i, bool more) {
  if (i == max_len) {
    return more ? 1 : 0;
  }
  int& res = DP[i][more];
  if (res != -1) {
    return res;
  }
  if (our[i] != '?') {
    buf += our[i];
    if (more) {
      res = dp(i + 1, more);
      if (!res) buf.erase((int)(buf.length()) - 1);
    } else {
      if (our[i] < their[i]) {
        res = 0;
        buf.erase((int)(buf.length()) - 1);
      } else {
        res = dp(i + 1, (our[i] > their[i]));
        if (!res) buf.erase((int)(buf.length()) - 1);
      }
    }
  } else {
    for (char d = more ? (i == our_start ? '1' : '0')
                       : (i == our_start ? max('1', their[i]) : their[i]);
         d <= '9'; ++d) {
      buf += d;
      res = dp(i + 1, (more | (d > their[i])));
      if (!res)
        buf.erase((int)(buf.length()) - 1);
      else
        break;
    }
  }
  return res;
}
inline int make_num(string x) {
  int a = 0;
  for (int i = 0; i < (int)(x.length()); i++) {
    a = a * 10 + x[i] - '0';
  }
  return a;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    max_len = max(max_len, (int)(s[i].length()));
  }
  for (int i = 0; i < n; i++) {
    start_pos[i] = max_len - (int)(s[i].length());
    string unshift = "";
    for (int j = 0; j < max_len - (int)(s[i].length()); j++) unshift += "0";
    s[i] = unshift + s[i];
  }
  if (s[0][start_pos[0]] == '?') {
    s[0][start_pos[0]] = '1';
  }
  for (int i = 0; i < (int)(s[0].length()); i++) {
    if (s[0][i] == '?') {
      s[0][i] = '0';
    }
  }
  for (int i = 1; i < n; i++) {
    memset(DP, -1, sizeof DP);
    our = s[i];
    their = s[i - 1];
    buf = "";
    our_start = start_pos[i];
    int res = dp(0, false);
    if (!res) {
      cout << "NO\n";
      return 0;
    }
    s[i] = buf;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << make_num(s[i]) << '\n';
  }
  return 0;
}
