#include <bits/stdc++.h>
using namespace std;
string str[111111];
int num[10];
string check(string s, int num) {
  for (int i = s.size() - 1; i >= 0; i--)
    if (s[i] == '?') {
      s[i] = num % 10 + '0';
      num /= 10;
    }
  return s;
}
bool bin(string x, string &y) {
  if (x.size() > y.size() || x == y) return false;
  if (x.size() < y.size()) {
    for (int i = 0; i < y.size(); i++)
      if (y[i] == '?') y[i] = i == 0 ? '1' : '0';
    return true;
  }
  int cnt = 0;
  for (int i = 0; i < y.size(); i++)
    if (y[i] == '?') cnt++;
  int l = 0, r = num[cnt] - 1;
  if (cnt == 0) return x < y ? true : false;
  string ans = "";
  while (l <= r) {
    int mid = (l + r) >> 1;
    string s = check(y, mid);
    if (s > x) {
      ans = s;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  if (ans == "") return false;
  y = ans;
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> str[i];
  num[0] = 1;
  for (int i = 1; i <= 8; i++) num[i] = num[i - 1] * 10;
  for (int i = 0; i < str[0].size(); i++)
    if (str[0][i] == '?') str[0][i] = i == 0 ? '1' : '0';
  bool flag = true;
  for (int i = 1; i < n; i++) {
    bool ok = bin(str[i - 1], str[i]);
    if (!ok) {
      flag = false;
      break;
    }
  }
  if (!flag)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) cout << str[i] << endl;
  }
  return 0;
}
