#include <bits/stdc++.h>
using namespace std;
int n;
vector<char> g[100500];
void say() {
  cout << "NO";
  exit(0);
}
void update(int x) {
  if (g[x].size() < g[x - 1].size())
    say();
  else if (g[x].size() > g[x - 1].size()) {
    for (int i = 0; i < g[x].size(); i++) {
      if (g[x][i] == '?') {
        if (i == 0)
          g[x][i] = '1';
        else
          g[x][i] = '0';
      }
    }
  } else {
    bool more = 0;
    int last = -1;
    vector<int> ques;
    for (int i = 0; i < g[x].size(); i++) {
      if (g[x][i] != '?') {
        if (g[x - 1][i] > g[x][i]) {
          if (!more) {
            if (last == -1) say();
            g[x][last]++;
            for (int j = 0; j < ques.size(); j++) {
              if (ques[j] > last) {
                g[x][ques[j]] = '0';
              }
            }
            more = 1;
          }
        } else if (g[x][i] > g[x - 1][i]) {
          more = 1;
        }
      } else {
        ques.push_back(i);
        if (more) {
          g[x][i] = '0';
          last = i;
        } else {
          g[x][i] = g[x - 1][i];
          if (g[x][i] != '9') last = i;
        }
      }
    }
    if (!more) {
      if (last == -1)
        say();
      else {
        g[x][last]++;
        for (int j = 0; j < ques.size(); j++) {
          if (ques[j] > last) {
            g[x][ques[j]] = '0';
          }
        }
      }
    }
  }
}
int main() {
  cin >> n;
  string s;
  getline(cin, s);
  for (int i = 1; i <= n; i++) {
    getline(cin, s);
    for (int j = 0; j < s.length(); j++) {
      g[i].push_back(s[j]);
    }
  }
  for (int i = 0; i < g[1].size(); i++) {
    if (g[1][i] == '?') {
      if (i == 0)
        g[1][i] = '1';
      else
        g[1][i] = '0';
    }
  }
  for (int j = 2; j <= n; j++) update(j);
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      cout << g[i][j];
    }
    cout << "\n";
  }
  return 0;
}
