#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::fixed;
using std::ios_base;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::ostream;
using std::pair;
using std::set;
using std::setprecision;
using std::string;
using std::swap;
using std::vector;
vector<int> result;
int main() {
  ios_base::ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long last = -1;
  for (int i = 0; i < (n); ++i) {
    string s;
    cin >> s;
    long long pot = 1;
    long long sum = 0;
    vector<int> q;
    for (int j = 0; j < (s.size()); ++j) {
      char x = s[s.size() - j - 1];
      int temp = x == '?' ? 9 : (int)x - (int)'0';
      if (x == '?') {
        q.push_back(s.size() - j - 1);
      }
      sum += temp * pot;
      pot *= 10;
    }
    reverse(q.begin(), q.end());
    for (__typeof((q).begin()) it = ((q).begin()); it != (q).end(); ++it) {
      long long dig = 9;
      long long lastdig = dig;
      long long bot = (*it) == 0 ? 1 : 0;
      long long lastsum = sum;
      pot = powl(10, s.size() - (*it) - 1);
      while (dig >= bot && sum > last) {
        lastdig = dig;
        lastsum = sum;
        dig--;
        sum -= pot;
      }
      sum = lastsum;
    }
    if (last >= sum) {
      cout << "NO" << endl;
      return 0;
    } else {
      last = sum;
      result.push_back(sum);
    }
  }
  cout << "YES" << endl;
  for (__typeof((result).begin()) it = ((result).begin()); it != (result).end();
       ++it) {
    cout << (*it) << endl;
  }
  return 0;
}
