#include <bits/stdc++.h>
using namespace std;
int n, sign;
char s[100005][10];
void solve(int x) {
  int len = strlen(s[x]), temp = 0;
  if (len > strlen(s[x - 1])) {
    if (s[x][0] == '?') s[x][0] = '1';
    for (int i = 1; i < len; i++) {
      if (s[x][i] == '?') s[x][i] = '0';
    }
    return;
  }
  if (len < strlen(s[x - 1])) {
    sign = 0;
    return;
  }
  for (int i = 0; i < len; i++)
    if (s[x][i] != '?' && s[x][i] != s[x - 1][i]) {
      for (int j = i + 1; j < len; j++) {
        if (s[x][j] == '?') s[x][j] = '0';
      }
      len = i + 1;
      if (s[x][i] > s[x - 1][i]) temp = 1;
      break;
    }
  for (int i = len - 1; i >= 0; i--)
    if (s[x][i] == '?') {
      if (temp)
        s[x][i] = s[x - 1][i];
      else if (s[x - 1][i] < '9') {
        s[x][i] = s[x - 1][i] + 1;
        temp = 1;
      } else
        s[x][i] = '0';
    }
  if (!temp) sign = 0;
}
int main() {
  scanf("%d", &n);
  sign = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    solve(i);
  }
  if (sign) {
    printf("YES\n");
    for (int i = 1; i <= n; i++) printf("%s\n", s[i]);
  } else
    printf("NO\n");
  return 0;
}
