#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1 << 17;
string s[N];
bool can[10];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (auto i = (0); i < (n); ++i) cin >> s[i];
  for (auto i = (0); i < (n); ++i) {
    if (!i || int((s[i]).size()) > int((s[i - 1]).size())) {
      if (s[i][0] == '?') s[i][0] = '1';
      for (auto j = (1); j < (int((s[i]).size())); ++j)
        if (s[i][j] == '?') s[i][j] = '0';
    } else if (int((s[i - 1]).size()) > int((s[i]).size()))
      return cout << "NO", 0;
    else {
      bool flip_point = 0;
      int pos = int((s[i]).size());
      for (auto j = (0); j < (int((s[i]).size())); ++j) {
        if (s[i][j] != '?' && s[i][j] != s[i - 1][j]) {
          if (s[i][j] > s[i - 1][j]) flip_point = true;
          pos = j + 1;
          break;
        }
      }
      for (auto j = (pos); j < (int((s[i]).size())); ++j)
        if (s[i][j] == '?') s[i][j] = '0';
      if (flip_point) {
        for (auto j = (0); j < (pos); ++j)
          if (s[i][j] == '?') s[i][j] = s[i - 1][j];
      } else {
        bool changed = false;
        for (auto j = (pos); j-- > (0);) {
          if (s[i][j] == '?') {
            if (changed)
              s[i][j] = s[i - 1][j];
            else if (s[i - 1][j] == '9')
              s[i][j] = '0';
            else {
              s[i][j] = s[i - 1][j] + 1;
              changed = true;
            }
          }
        }
      }
      if (s[i] <= s[i - 1]) return cout << "NO", 0;
    }
  }
  cout << "YES\n";
  for (auto i = (0); i < (n); ++i) cout << s[i] << '\n';
}
