#include <bits/stdc++.h>
using namespace std;
void fin(int n) {
  string s;
  for (int i = 0; i < n; i++) cin >> s;
  cout << "NO" << endl;
  exit(0);
}
string change(string k, string t) {
  string ans = "";
  for (int i = 0; i <= k.length(); i++) ans += '9';
  for (int i = 0; i < k.length(); i++) {
    string s = k;
    bool ch = 1;
    for (int j = 0; j < s.length(); j++) {
      if (j < i) {
        if (s[j] == '?')
          s[j] = t[j];
        else if (s[j] < t[j]) {
          j = s.length();
          ch = 0;
        }
      }
      if (j == i) {
        if (t[j] == '9' || (s[j] != '?' && s[j] <= t[j])) {
          ch = 0;
          j = s.length();
        } else if (s[j] == '?')
          s[j] = t[j] + 1;
      }
      if (j > i)
        if (s[j] == '?') s[j] = '0';
    }
    for (int j = 0; j < s.length(); j++)
      if (k[j] != '?' && s[j] != k[j])
        ch = 0;
      else if (s[j] == '?')
        ch = 0;
    if (ch) ans = min(ans, s);
  }
  return ans;
}
int main() {
  int n;
  string s, t;
  vector<string> ans;
  cin >> n;
  cin >> s;
  if (s[0] == '?') s[0] = '1';
  for (int i = 1; i < s.size(); i++)
    if (s[i] == '?') s[i] = '0';
  t = s;
  ans.push_back(t);
  for (int i = 1; i < n; i++) {
    cin >> s;
    if (s.length() > t.length()) {
      if (s[0] == '?') s[0] = '1';
      for (int i = 0; i < s.length(); i++)
        if (s[i] == '?') s[i] = '0';
      ans.push_back(s);
      t = s;
      continue;
    }
    if (s.length() < t.length()) fin(n - i - 1);
    string k = change(s, t);
    if (k.length() > s.length())
      fin(n - i - 1);
    else
      ans.push_back(k);
    t = k;
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}
