#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> p;
string cmp;
string now;
string full(string sb) {
  string re = "";
  for (int i = 0; i < sb.length(); i++) {
    if (sb[i] == '?')
      re += '9';
    else
      re += sb[i];
  }
  return re;
}
bool bigger(string fuck, string sb) {
  if (fuck.length() < sb.length()) return 0;
  if (fuck.length() > sb.length()) {
    for (int i = 0; i < fuck.length(); i++) {
      if (fuck[i] == '?') {
        if (i == 0)
          fuck[i] = '1';
        else
          fuck[i] = '0';
      }
    }
    p.push_back(fuck);
    return 1;
  }
  string re = "";
  int len = fuck.length();
  if (full(fuck) <= sb) return 0;
  bool ok = 0;
  for (int i = 0; i < len; i++) {
    if (fuck[i] == '?') {
      if (!ok) {
        if (re + sb[i] + full(fuck.substr(i + 1, len)) > sb)
          re = re + sb[i];
        else {
          re = re + (char)(sb[i] + 1);
          ok = 1;
        }
      } else
        re = re + '0';
    } else {
      if (fuck[i] > sb[i]) ok = 1;
      re = re + fuck[i];
    }
  }
  p.push_back(re);
  return 1;
}
int main() {
  scanf("%d", &n);
  char sb[10];
  for (int i = 0; i < n; i++) {
    scanf("%s", sb);
    cmp = (string)sb;
    if (!bigger(cmp, now)) {
      printf("NO\n");
      return 0;
    }
    now = p[i];
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    cout << p[i] << endl;
  }
}
