#include <bits/stdc++.h>
using namespace std;
string arr[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  string S = arr[0];
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] != '?') continue;
    if (i)
      S[i] = '0';
    else if (!i)
      S[i] = '1';
  }
  arr[0] = S;
  for (int i = 1; i < n; i++) {
    string prev, cur;
    prev = arr[i - 1];
    cur = arr[i];
    if ((int)cur.size() < (int)prev.size()) {
      printf("NO\n");
      return 0;
    } else if ((int)cur.size() > (int)prev.size()) {
      for (int j = 0; j < (int)cur.size(); j++) {
        if (cur[j] != '?') continue;
        if (!j)
          cur[j] = '1';
        else
          cur[j] = '0';
      }
    } else {
      if (cur == prev) {
        printf("NO\n");
        return 0;
      }
      int ind = -1, state;
      for (int j = 0; j < (int)cur.size(); j++) {
        if (cur[j] != '?' && prev[j] != cur[j]) {
          ind = j;
          if (cur[j] > prev[j])
            state = 1;
          else
            state = 2;
          break;
        }
      }
      if (ind == -1) {
        bool flag = 0;
        for (int j = (int)cur.size() - 1; j >= 0; j--) {
          if (cur[j] != '?') continue;
          if (!flag) {
            if (prev[j] != '9') {
              cur[j] = prev[j] + 1;
              flag = 1;
            } else {
              cur[j] = '0';
            }
          } else {
            cur[j] = prev[j];
          }
        }
        if (cur == prev || !flag) {
          printf("NO\n");
          return 0;
        }
      } else if (state == 1) {
        for (int j = 0; j < ind; j++) {
          if (cur[j] == '?') cur[j] = prev[j];
        }
        for (int j = ind + 1; j < (int)cur.size(); j++) {
          if (cur[j] == '?') cur[j] = '0';
        }
      } else if (state == 2) {
        int before = -1;
        for (int j = ind - 1; j >= 0; j--) {
          if (cur[j] == '?' && prev[j] != '9') {
            before = j;
            break;
          }
        }
        if (before == -1) {
          printf("NO\n");
          return 0;
        } else {
          cur[before] = prev[before] + 1;
          for (int j = before - 1; j >= 0; j--) {
            if (cur[j] == '?') {
              cur[j] = prev[j];
            }
          }
          for (int j = before + 1; j < (int)cur.size(); j++) {
            if (cur[j] == '?') {
              cur[j] = '0';
            }
          }
        }
      }
    }
    arr[i] = cur;
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) printf("%s\n", arr[i].c_str());
}
