#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Pt {
  T x, y;
  void scan() { cin >> x >> y; }
};
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
template <typename T>
inline int sign(const T& a) {
  return a < 0 ? -1 : a > 0;
}
void task();
int main() {
  task();
  return 0;
}
int n;
string s[int(1e5) + 10];
void task() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  string cur = "";
  for (int i = 0; i < n; ++i) {
    if (s[i].length() < cur.length()) {
      cout << "NO";
      return;
    }
    if (s[i].length() > cur.length()) {
      for (int j = 0; j < s[i].length(); ++j)
        if (s[i][j] == '?') s[i][j] = j == 0 ? '1' : '0';
      cur = s[i];
      continue;
    }
    string t = "";
    for (int j = 0; j < cur.length(); ++j) {
      string tmp = s[i];
      if (tmp[j] != '?' && tmp[j] <= cur[j]) continue;
      if (tmp[j] == '?' && cur[j] == '9') continue;
      if (tmp[j] == '?') tmp[j] = cur[j] + 1;
      for (int k = j + 1; k < cur.length(); ++k)
        if (tmp[k] == '?') tmp[k] = '0';
      int ok = 1;
      for (int k = j - 1; k >= 0; --k)
        if (tmp[k] == '?')
          tmp[k] = cur[k];
        else if (tmp[k] != cur[k])
          ok = 0;
      if (ok) {
        if (t.empty() || tmp < t) t = tmp;
      }
    }
    if (t.empty()) {
      cout << "NO";
      return;
    }
    s[i] = t;
    cur = t;
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) cout << s[i] << "\n";
}
