#include <bits/stdc++.h>
using namespace std;
string s[100010], a, b;
int n;
bool total;
void triv_case() {
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == '?' && i != 0)
      a[i] = '0';
    else if (a[i] == '?')
      a[i] = '1';
  }
}
int nadji_cifru() {
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != '?' && b[i] > a[i]) return (-1);
    if (a[i] > b[i] && a[i] != '?') return i;
  }
  return (-1);
}
int nadji_gornju_vecu_cifru() {
  int last_idx = -1;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != '?' && a[i] > b[i]) return (-1);
    if (a[i] != '?' && b[i] > a[i])
      return last_idx;
    else if (a[i] == '?')
      last_idx = i;
  }
  return (-1);
}
bool moguce() {
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == '?')
      return true;
    else if (a[i] != '?' && a[i] > b[i])
      return true;
    else if (b[i] > a[i])
      return false;
  }
}
void napravi() {
  bool prvi_upitnik = false, prenos = false;
  for (int i = a.length() - 1; i >= 0; i--) {
    if (a[i] == '?' && !prvi_upitnik) {
      a[i] = b[i];
      if (a[i] == '9') {
        a[i] = '0';
        prenos = true;
      } else
        a[i]++;
      prvi_upitnik = true;
    } else if (a[i] == '?') {
      a[i] = b[i];
      if (prenos) {
        if (a[i] == '9')
          a[i] = '0';
        else {
          a[i]++;
          prenos = false;
        }
      }
    }
  }
  if (a <= b) total = true;
}
void zajebano_napravi(int start) {
  int prenos = false;
  a[start] = b[start];
  if (a[start] == '9') {
    a[start] = '0';
    prenos = true;
  } else
    a[start]++;
  for (int i = start - 1; i >= 0; i--) {
    if (a[i] == '?') {
      a[i] = b[i];
      if (prenos) {
        if (a[i] == '9')
          a[i] = '0';
        else {
          a[i]++;
          prenos = false;
        }
      }
    }
  }
  for (int i = start + 1; i < a.length(); i++) {
    if (a[i] == '?') a[i] = '0';
  }
}
void iste_duzine() {
  if (a.find_first_of('?') == (-1)) {
    if (a <= b) total = true;
  } else {
    if (moguce()) {
      int jebem_ti_mater = nadji_gornju_vecu_cifru();
      if (jebem_ti_mater != -1) {
        zajebano_napravi(jebem_ti_mater);
      } else {
        int pos_cifra = nadji_cifru();
        if (pos_cifra != -1) {
          for (int i = 0; i < a.length(); i++) {
            if (i < pos_cifra && a[i] == '?')
              a[i] = b[i];
            else if (a[i] == '?')
              a[i] = '0';
          }
        } else
          napravi();
      }
    } else
      total = true;
  }
}
int main() {
  cin >> n;
  s[0] = "";
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (total) continue;
    if (s[i].length() < s[i - 1].length())
      total = true;
    else if (s[i].length() > s[i - 1].length()) {
      a = s[i];
      triv_case();
      s[i] = a;
    } else {
      a = s[i];
      b = s[i - 1];
      iste_duzine();
      s[i] = a;
      s[i - 1] = b;
    }
  }
  if (total) {
    puts("NO");
  } else {
    puts("YES");
    for (int i = 1; i <= n; i++) cout << s[i] << "\n";
  }
  return 0;
}
