#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
int vec[maxn];
bool check(int mid, char s[], int last) {
  char t[10];
  int len = (int)strlen(s);
  for (int i = len - 1; i >= 0; i--) {
    if (s[i] == '?') {
      t[i] = '0' + mid % 10;
      mid /= 10;
    } else {
      t[i] = s[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < len; i++) {
    ans = ans * 10 + (t[i] - '0');
  }
  return ans > last;
}
int solve(char s[], int last) {
  int l = 0, r = 0;
  int len = (int)strlen(s);
  if (s[0] == '?') {
    l = 1;
    r = 9;
  }
  for (int i = 1; i < len; i++) {
    if (s[i] == '?') {
      l = l * 10 + 0;
      r = r * 10 + 9;
    }
  }
  int ans = inf;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid, s, last)) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  if (ans == inf) return -1;
  for (int i = len - 1; i >= 0; i--) {
    if (s[i] == '?') {
      s[i] = '0' + ans % 10;
      ans /= 10;
    }
  }
  int sum = 0;
  for (int i = 0; i < len; i++) {
    sum = sum * 10 + (s[i] - '0');
  }
  return sum;
}
int main() {
  int n;
  scanf("%d", &n);
  int last = -1;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    char s[10];
    scanf("%s", s);
    if (!ok) continue;
    last = solve(s, last);
    vec[i] = last;
    if (last == -1) {
      ok = false;
    }
  }
  if (ok) {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      printf("%d\n", vec[i]);
    }
  } else {
    printf("NO\n");
  }
  return 0;
}
