#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 1e5 + 10;
int a[maxn];
int base[20];
int n, cur, last, str;
char s[maxn], t[maxn];
void pre() {
  int bas = 1;
  for (int i = 1; i <= 10; i++) {
    base[i] = bas;
    bas *= 10;
  }
}
int solve(int id) {
  int ans;
  if (cur > last) {
    int ans;
    for (int i = 1; i <= cur; i++) {
      if (s[i] == '?') {
        if (i == 1)
          t[i] = '1';
        else
          t[i] = '0';
      } else
        t[i] = s[i];
    }
    t[cur + 1] = '\0';
    ans = atoi(t + 1);
    return ans;
  } else {
    for (int i = 1; i <= cur; i++) {
      if (s[i] == '?')
        t[i] = '9';
      else
        t[i] = s[i];
    }
    t[cur + 1] = '\0';
    ans = atoi(t + 1);
    if (ans <= a[id - 1])
      return -1;
    else {
      for (int i = 1; i <= cur; i++) {
        if (s[i] == '?') {
          int cnt = 0;
          while (ans - base[cur - i + 1] > a[id - 1]) {
            ans -= base[cur - i + 1];
            cnt++;
            if (cnt >= 9) break;
          }
        }
      }
      return ans;
    }
  }
}
int solve2(int id) {
  int ans;
  if (cur > last) {
    for (int i = 1; i <= cur; i++) {
      if (s[i] == '?') {
        if (i == 1)
          t[i] = '1';
        else
          t[i] = '0';
      } else
        t[i] = s[i];
    }
    t[cur + 1] = '\0';
    ans = atoi(t + 1);
    return ans;
  } else {
    for (int i = 1; i <= n; i++) {
      if (s[i] == '?')
        t[i] = '9';
      else
        t[i] = s[i];
    }
    t[cur + 1] = '\0';
    ans = atoi(t + 1);
    if (ans <= a[id - 1])
      return -1;
    else {
      for (int i = 1; i <= cur; i++) {
        if (s[i] == '?') {
          int cnt = 0;
          while (ans - base[cur + 1 - i] > a[id - 1]) {
            ans -= base[cur + 1 - i];
            cnt++;
            if (cnt >= 9) break;
          }
        }
      }
      return ans;
    }
  }
}
int main() {
  pre();
  while (scanf("%d", &n) != EOF) {
    int ok = 0;
    last = 0;
    a[0] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%s", s + 1);
      if (ok) continue;
      cur = strlen(s + 1);
      if (last > cur)
        ok = 1;
      else {
        int tm = solve(i);
        if (a[i - 1] >= tm)
          ok = 1;
        else {
          a[i] = tm;
        }
      }
      last = cur;
    }
    if (ok)
      printf("NO\n");
    else {
      printf("YES\n");
      for (int i = 1; i <= n; i++) {
        printf("%d\n", a[i]);
      }
    }
  }
  return 0;
}
