#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, l, r, mid, ans, cnt, last, len, flag = 1;
int rlis[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
char s[10];
int lis[100010];
int num = 0;
int check(int x) {
  int y[10], cou = 0, res = 0;
  for (int i = 0; i < num; ++i) {
    y[cou++] = x % 10;
    x /= 10;
  }
  for (int i = 0; i < len; ++i) {
    if (s[i] != '?') {
      res *= 10;
      res = res + s[i] - '0';
    } else {
      res *= 10;
      res = res + y[--cou];
    }
  }
  return res;
}
void bs() {
  l = 0, r = rlis[num], ans = -1;
  if (s[0] == '?') l = rlis[num - 1];
  while (l <= r) {
    mid = (l + r) / 2;
    int now = check(mid);
    if (now > last) {
      r = mid - 1, ans = now;
    } else
      l = mid + 1;
  }
}
int main() {
  scanf("%d", &n);
  last = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    if (!flag) continue;
    num = 0;
    len = strlen(s);
    for (int j = 0; j < len; ++j) {
      if (s[j] == '?') ++num;
    }
    bs();
    if (ans > last) {
      lis[cnt++] = ans;
      last = ans;
    } else
      flag = 0;
  }
  if (flag) {
    printf("YES\n");
    for (int i = 0; i < n; ++i) printf("%d\n", lis[i]);
  } else
    printf("NO\n");
  return 0;
}
