#include <bits/stdc++.h>
using namespace std;
inline bool read(int& val) { return scanf("%d", &val) != -1; }
inline bool read(long long& val) { return scanf("%I64d", &val) != -1; }
inline bool read(double& val) { return scanf("%lf", &val) != -1; }
inline bool read(char* val) { return scanf("%s", val) != -1; }
template <class T1, class T2>
inline bool read(T1& a, T2& b) {
  return read(a) && read(b);
}
template <class T1, class T2, class T3>
inline bool read(T1& a, T2& b, T3& c) {
  return read(a) && read(b) && read(c);
}
template <class T1, class T2, class T3, class T4>
inline bool read(T1& a, T2& b, T3& c, T4& d) {
  return read(a) && read(b) && read(c) && read(d);
}
template <class T1, class T2, class T3, class T4, class T5>
inline bool read(T1& a, T2& b, T3& c, T4& d, T5& e) {
  return read(a) && read(b) && read(c) && read(d) && read(e);
}
const int N = 111111;
char num[N][10];
int main() {
  int n;
  read(n);
  for (int i = 0, _ = n; i < _; i++) read(num[i]);
  char cur[10] = {0};
  int len = strlen(cur);
  for (int i = 0, _ = n; i < _; i++) {
    int m = strlen(num[i]);
    if (m < len) {
      puts("NO");
      return 0;
    } else if (m > len) {
      for (int j = 0, _ = m; j < _; j++)
        if (num[i][j] == '?') num[i][j] = j > 0 ? '0' : '1';
      len = m;
      for (int j = 0, _ = 10; j < _; j++) cur[j] = num[i][j];
    } else {
      bool more[10] = {false};
      for (int j = m - 1; j >= 0; j--) {
        more[j] = more[j + 1];
        if (num[i][j] == '?') {
          if (cur[j] != '9') more[j] = true;
        } else {
          if (num[i][j] > cur[j]) more[j] = true;
          if (num[i][j] < cur[j]) more[j] = false;
        }
      }
      if (!more[0]) {
        puts("NO");
        return 0;
      }
      bool over = false;
      for (int j = 0, _ = m; j < _; j++) {
        if (num[i][j] == '?') {
          if (over)
            num[i][j] = '0';
          else if (more[j + 1])
            num[i][j] = cur[j];
          else
            num[i][j] = cur[j] + 1, over = true;
        } else if (num[i][j] > cur[j])
          over = true;
      }
      for (int j = 0, _ = 10; j < _; j++) cur[j] = num[i][j];
    }
  }
  puts("YES");
  for (int i = 0, _ = n; i < _; i++) puts(num[i]);
  return 0;
}
