#include <bits/stdc++.h>
using namespace std;
int n;
char sir[100005][10], era[100005][10];
int v[10], nrcif = 0;
int maimare(int ind, int n) {
  int i, egale = 1;
  for (i = 0; i < n; i++) {
    if ((sir[ind][i] - '0' < v[i]) && (egale)) return 0;
    if (sir[ind][i] - '0' > v[i]) egale = 0;
  }
  if (egale) return 0;
  return 1;
}
int act(int ind) {
  int i, j, n = strlen(sir[ind]), egale, cif;
  for (i = 0; i < n; i++) era[ind][i] = '0';
  if (nrcif > n) return 0;
  if (nrcif < n) {
    for (i = 0; i < n; i++)
      if (sir[ind][i] == '?') {
        if (i == 0)
          sir[ind][i] = '1';
        else
          sir[ind][i] = '0';
      }
    nrcif = n;
    for (i = 0; i < n; i++) v[i] = sir[ind][i] - '0';
    return 1;
  }
  egale = 1;
  for (i = 0; i < n; i++) {
    if (sir[ind][i] == '?') {
      cif = 9;
      sir[ind][i] = '9';
      era[ind][i] = '?';
    } else
      cif = sir[ind][i] - '0';
    if (cif > v[i])
      egale = 0;
    else if ((cif < v[i]) && egale)
      return 0;
  }
  if (egale) return 0;
  char ch;
  for (i = 0; i < n; i++)
    if (era[ind][i] == '?') {
      for (j = 8; j >= 0; j--)
        if ((j == 0) && (i == 0))
          ;
        else {
          ch = sir[ind][i];
          sir[ind][i] = j + '0';
          if (!maimare(ind, n)) {
            sir[ind][i] = ch;
            break;
          }
        }
    }
  nrcif = n;
  for (i = 0; i < n; i++) v[i] = sir[ind][i] - '0';
  return 1;
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> sir[i];
  for (i = 1; i <= n; i++)
    if (!act(i)) {
      cout << "NO";
      return 0;
    }
  cout << "YES\n";
  for (i = 1; i <= n; i++) cout << sir[i] << "\n";
  return 0;
}
