#include <bits/stdc++.h>
using namespace std;
char str[(int)1e5 + 5][10];
char len[(int)1e5 + 5];
int N;
bool dfs(int i, int x, int flag) {
  if (x > len[i]) {
    if (flag) return true;
    return false;
  }
  if (str[i][x] != '?') {
    if (!flag && str[i][x] < str[i - 1][x]) return false;
    return dfs(i, x + 1, flag | str[i][x] > str[i - 1][x]);
  } else {
    if (flag) {
      str[i][x] = '0';
      if (dfs(i, x + 1, flag)) return true;
      str[i][x] = '?';
      return false;
    }
    for (char k = str[i - 1][x]; k <= '9'; k++) {
      str[i][x] = k;
      if (dfs(i, x + 1, k > str[i - 1][x])) return true;
    }
    str[i][x] = '?';
    return false;
  }
}
bool judge(int i) {
  if (len[i] < len[i - 1]) return false;
  if (len[i] > len[i - 1]) {
    if (str[i][0] == '?') str[i][0] = '1';
    for (int j = 1; j < len[i]; j++)
      if (str[i][j] == '?') str[i][j] = '0';
    return true;
  }
  if (dfs(i, 0, 0)) return true;
  return false;
}
bool fuck() {
  if (N == 1) return true;
  for (int i = 1; i < N; i++)
    if (!judge(i)) return false;
  return true;
}
int main() {
  while (cin >> N) {
    for (int i = 0; i < N; i++) {
      cin >> str[i];
      len[i] = strlen(str[i]);
    }
    for (int i = 0; i < len[0]; i++) {
      if (str[0][i] == '?') str[0][i] = (i == 0) ? '1' : '0';
    }
    if (fuck()) {
      cout << "YES" << endl;
      for (int i = 0; i < N; i++) cout << str[i] << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
