#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
  return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  os << '[';
  for (unsigned long long i = 0; i < a.size(); i++)
    os << a[i] << (i < a.size() - 1 ? ", " : "");
  os << ']';
  return os;
}
string make(string pre, string ori) {
  string ret = ori;
  if (ret.size() < pre.size()) return "-1";
  if (ret.size() > pre.size()) {
    for (auto &it : ret)
      if (it == '?') it = '0';
    if (ori[0] == '?') ret[0] = '1';
    return ret;
  }
  bool gre = false;
  for (long long i = (long long)0; i <= (long long)ret.size() - 1; i++) {
    if (ret[i] == '?') {
      if (gre)
        ret[i] = '0';
      else {
        auto tmp = ret;
        tmp[i] = pre[i];
        for (long long j = (long long)i + 1; j <= (long long)tmp.size() - 1;
             j++)
          if (tmp[j] == '?') tmp[j] = '9';
        if (tmp > pre) {
          ret[i] = pre[i];
          continue;
        }
        if (pre[i] == '9') return "-1";
        ret[i] = pre[i] + 1;
        gre = true;
      }
    } else {
      if (gre) continue;
      if (ret[i] != pre[i]) {
        if (ret[i] < pre[i]) return "-1";
        gre = true;
      }
    }
  }
  if (!gre) return "-1";
  return ret;
}
long long n;
vector<string> ans;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string pre;
  pre = "0";
  cin >> n;
  for (long long i = (long long)1; i <= (long long)n; i++) {
    string s;
    cin >> s;
    auto rec = make(pre, s);
    if (rec == "-1") {
      cout << "NO" << '\n';
      return 0;
    }
    pre = rec;
    ans.push_back(rec);
  }
  cout << "YES" << '\n';
  for (auto it : ans) cout << it << '\n';
}
