#include <bits/stdc++.h>
using namespace std;
string getmin(string prev, string cur) {
  if (prev.length() < cur.length()) {
    for (int i = 0; i < cur.length(); i++) {
      if (cur[i] == '?') cur[i] = (i == 0) ? '1' : '0';
    }
    return cur;
  }
  if (prev.length() > cur.length()) return "";
  int fmsm = 100;
  for (int i = 0; i < cur.length(); i++) {
    if (cur[i] == '?') continue;
    if (cur[i] != prev[i]) {
      fmsm = i;
      break;
    }
  }
  int nm = 0;
  for (int i = 0; i < cur.length(); i++) {
    if (i == fmsm) {
      if (cur[i] < prev[i]) nm++;
    }
    if (cur[i] == '?') {
      if (i < fmsm)
        nm = nm * 10 + prev[i] - '0';
      else {
        nm *= 10;
      }
    }
  }
  if (fmsm == 100) nm++;
  for (int i = cur.length() - 1; i >= 0; i--) {
    if (cur[i] == '?') {
      cur[i] = '0' + nm % 10;
      nm /= 10;
    }
  }
  if (nm) return "";
  return cur;
}
int main() {
  int n;
  scanf("%d", &n);
  string cur = "";
  vector<string> nums;
  for (int i = 0; i < n; i++) {
    char ch[32];
    scanf(" %s", ch);
    string chs(ch);
    string x = getmin(cur, chs);
    if (x.empty()) {
      printf("NO\n");
      return 0;
    }
    nums.push_back(x);
    cur = x;
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) printf("%s\n", nums[i].c_str());
  return 0;
}
