#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E5 + 5;
int n;
string s[MAXN];
int main() {
  scanf("%d\n", &n);
  for (int i = 0, _n = n; i < _n; ++i) cin >> s[i];
  string last = "0";
  for (int i = 0, _n = n; i < _n; ++i) {
    bool isGreater = 0;
    int lastPos[s[i].size() + 1];
    lastPos[0] = -1;
    for (int j = 0, _n = s[i].size() + 1; j < _n; ++j)
      if (j > 0)
        if (s[i][j - 1] == '?')
          lastPos[j] = j - 1;
        else
          lastPos[j] = lastPos[j - 1];
    if (s[i].size() > last.size()) {
      for (int j = 0; j < int(s[i].size()); ++j)
        if (s[i][j] == '?') {
          if (j == 0)
            s[i][j] = '1';
          else
            s[i][j] = '0';
        }
      isGreater = 1;
    } else if (s[i].size() < last.size()) {
      puts("NO");
      return 0;
    } else {
      for (int j = 0; j < int(s[i].size()); ++j)
        if (s[i][j] != '?') {
          if (s[i][j] > last[j])
            isGreater = 1;
          else if (s[i][j] < last[j] && !isGreater) {
            int idx = lastPos[j];
            while (idx >= 0 && last[idx] == '9')
              s[i][idx] = '0', idx = lastPos[idx];
            if (idx == -1) {
              puts("NO");
              return 0;
            } else {
              s[i][idx] = last[idx] + 1;
              isGreater = 1;
            }
          }
        } else {
          if (!isGreater)
            s[i][j] = last[j];
          else
            s[i][j] = j > 0 ? '0' : '1';
        }
    }
    if (!isGreater) {
      int p = lastPos[s[i].size()];
      while (p >= 0 && last[p] == '9') s[i][p] = '0', p = lastPos[p];
      if (p >= 0)
        s[i][p] = last[p] + 1;
      else {
        puts("NO");
        return 0;
      }
    }
    last = s[i];
  }
  puts("YES");
  for (int i = 0, _n = n; i < _n; ++i) cout << s[i] << endl;
}
