#include <bits/stdc++.h>
using namespace std;
const int kn = 2e6 + 5, N = 1e5 + 5;
const long long mod = 1e9 + 7, mod2 = 1e9 + 9;
const long long base = 31, base1 = 37;
int n;
string cac[kn];
bool cmp(string a, string b) {
  if (a.size() != b.size()) return a.size() < b.size();
  return a < b;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> cac[i];
    if (i > 1 && cac[i].size() < cac[i - 1].size()) {
      cout << "NO";
      return 0;
    }
  }
  string tmp = cac[1];
  for (int i = 0; i < tmp.size(); i++)
    if (tmp[i] == '?') tmp[i] = '0';
  if (tmp[0] == '0') tmp[0] = '1';
  cac[1] = tmp;
  for (int i = 2; i <= n; i++) {
    int pos = -1;
    tmp = cac[i];
    if (cac[i].size() > cac[i - 1].size()) {
      for (int j = 0; j < cac[i].size(); j++) {
        if (tmp[j] == '?') tmp[j] = '0';
      }
      if (tmp[0] == '0') tmp[0] = '1';
      cac[i] = tmp;
    } else {
      int j;
      string tmp2 = cac[i - 1];
      for (j = 0; j < cac[i].size(); j++) {
        if (tmp[j] == '?') {
          if (tmp2[j] != '9') pos = j;
          continue;
        }
        if (tmp[j] < tmp2[j]) {
          break;
        }
        if (tmp[j] > tmp2[j]) {
          pos = j;
          break;
        }
      }
      for (j = 0; j < cac[i].size(); j++) {
        if (tmp[j] == '?') {
          if (j < pos) tmp[j] = tmp2[j];
          if (j == pos) tmp[j] = char(tmp2[j] + 1);
          if (j > pos) tmp[j] = '0';
        }
      }
      if (not cmp(tmp2, tmp)) {
        cout << "NO";
        return 0;
      }
      cac[i] = tmp;
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << cac[i] << endl;
  }
}
