#include <bits/stdc++.h>
using namespace std;
long long pwr[20];
long long gcd(long long a, long long b) {
  long long c;
  if (a > b) {
    c = a;
    a = b;
    b = c;
  }
  c = b % a;
  while (c > 0) {
    b = a;
    a = c;
    c = b % a;
  }
  return a;
}
long long minVal(string s) {
  long long val = 0;
  if (s[0] == '?')
    val = 1;
  else
    val = s[0] - '0';
  for (long long i = 1; i < s.size(); i++) {
    if (s[i] == '?') s[i] = '0';
    val = (val * 10) + (s[i] - '0');
  }
  return val;
}
long long addVal(string s, long long val) {
  if (val < 1) return 0;
  long d = log10((double)val);
  int l = s.size() - 1;
  if (s[l - d] != '?') {
    for (long long j = l - d - 1; j > -1; j--) {
      if (s[j] == '?') {
        return pwr[l - j];
      }
    }
    return -1;
  } else {
    long long p = pwr[d];
    long long firstDigit = val / p;
    long long sub = firstDigit * p;
    long long rest = addVal(s, val - sub);
    if ((firstDigit != 9 || rest != p) && (sub + rest) < 9 * pwr[l])
      return sub + rest;
    for (long long j = l - d - 1; j > -1; j--) {
      if (s[j] == '?') {
        return pwr[l - j];
      }
    }
    return -1;
  }
}
int main(void) {
  string s;
  long long N, maxVal = 0;
  bool possible = true;
  vector<long long> vals;
  pwr[0] = 1;
  for (int i = 1; i < 20; i++) pwr[i] = pwr[i - 1] * 10;
  cin >> N;
  cin >> s;
  if (s[0] == '?') s[0] = '1';
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '?') s[i] = '0';
    maxVal = maxVal * 10 + (s[i] - '0');
  }
  vals.push_back(maxVal);
  for (long long i = 1; i < N; i++) {
    cin >> s;
    if (possible) {
      maxVal = vals[i - 1];
      long long digits = 1 + log10((double)maxVal), val;
      if (digits > s.size()) {
        possible = false;
      } else if (digits == s.size()) {
        val = minVal(s);
        if (val <= maxVal) {
          long long inc = 1 + maxVal - val, t = 0;
          t = addVal(s, inc);
          if (t > 0)
            val += t;
          else {
            possible = false;
          }
        }
        vals.push_back(val);
      } else
        vals.push_back(minVal(s));
      if (possible && vals[i] <= vals[i - 1])
        cout << "ddd " << s << " " << maxVal << " " << vals[i];
    }
  }
  if (possible) {
    cout << "YES" << endl;
    for (long long i = 0; i < N; i++) cout << vals[i] << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
