#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<string, int>> arr[10];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    arr[s.size()].push_back(make_pair(s, i));
  }
  vector<int> ans(n);
  for (int d = 1; d <= 8; d++) {
    string prev = "";
    for (auto pp : arr[d]) {
      if (prev == "") {
        string s = pp.first;
        for (int i = d - 1; i >= 0; i--) {
          if (s[i] == '?') s[i] = (i == 0) ? '1' : '0';
        }
        ans[pp.second] = stoi(s);
        prev = s;
      } else {
        string s = pp.first;
        vector<string> tmp;
        string x = s;
        for (int i = 0; i < d; i++)
          if (x[i] == '?') x[i] = (i == 0) ? '1' : '0';
        if (x > prev) tmp.push_back(x);
        for (int i = 0; i < d; i++) {
          if (s[i] == '?') {
            string a = x, b = s;
            for (int j = 0; j < i; j++)
              if (s[j] == '?') a[j] = b[j] = prev[j];
            for (int j = i + 1; j < d; j++)
              if (s[j] == '?') a[j] = b[j] = '0';
            a[i] = b[i] = prev[i];
            if (prev[i] != '9') a[i]++;
            if (a > prev) tmp.push_back(a);
            if (b > prev) tmp.push_back(b);
          }
        }
        sort(begin(tmp), end(tmp));
        if (tmp.empty()) {
          cout << "NO" << endl;
          return (0);
        }
        ans[pp.second] = stoi(tmp.front());
        prev = tmp.front();
      }
    }
  }
  bool ok = true;
  for (int i = 1; i < n; i++) ok &= ans[i - 1] < ans[i];
  if (not ok) {
    cout << "NO" << endl;
    return (0);
  }
  cout << "YES" << endl;
  for (int ans_i : ans) cout << ans_i << endl;
  return (0);
}
