#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
string s[N];
vector<int> v[N];
bool cmp(string s1, string s2) {
  return (s1.length() > s2.length() ||
          (s1.length() == s2.length() && s1 >= s2));
}
bool solve(int n) {
  for (int i = 1; i <= n; i++) {
    if (cmp(s[i - 1], s[i])) return false;
    if (!v[i].empty()) {
      int sz = v[i].size();
      for (int j = 0; j < sz; j++) {
        char lim = (v[i][j] == 0) ? '1' : '0';
        while (s[i][v[i][j]] > lim) {
          s[i][v[i][j]]--;
          if (cmp(s[i - 1], s[i])) {
            s[i][v[i][j]]++;
            break;
          }
        }
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    int len = s[i].length();
    for (int j = 0; j < len; j++) {
      if (s[i][j] == '?') {
        s[i][j] = '9';
        v[i].push_back(j);
      }
    }
  }
  if (!solve(n))
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) cout << s[i] << endl;
  }
}
