#include <bits/stdc++.h>
char nums[100005][10];
int seq[100005];
char temp[10];
int N;
int min_p, max_p;
int last;
int len;
int e[10] = {1,      10,      100,      1000,      10000,
             100000, 1000000, 10000000, 100000000, 1000000000};
int check(int mid, int flag) {
  char tmp[20];
  int cnt = 0;
  for (int i = 0; i < flag; ++i) {
    tmp[++cnt] = mid % 10 + '0';
    mid = mid / 10;
  }
  int ans = 0;
  for (int i = 0; i < len; ++i) {
    if (temp[i] != '?')
      ans = ans * 10 + temp[i] - '0';
    else
      ans = ans * 10 + tmp[cnt--] - '0';
  }
  return ans;
}
int get_num() {
  int l, r, mid;
  len = 0;
  int flag = 0;
  int num = 0;
  while (temp[len]) {
    if (temp[len] == '?') {
      flag++;
    } else {
      num = num * 10 + temp[len] - '0';
    }
    ++len;
  }
  if (!flag) return num;
  l = 0;
  if (temp[0] == '?') l = e[flag - 1];
  r = e[flag] - 1;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(mid, flag) > last) {
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return check(l, flag);
}
void num2str(int row, int num) {
  int len = 0;
  char temp_num[10];
  while (num) {
    temp_num[len++] = num % 10;
    num /= 10;
  }
  for (int i = 0; i < len; ++i) {
    nums[row][i] = temp_num[len - 1 - i] + '0';
  }
  nums[row][len] = '\0';
}
int main() {
  scanf("%d", &N);
  last = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%s", temp);
    int num = get_num();
    if (num <= last) {
      printf("NO\n");
      return 0;
    } else {
      seq[i] = num;
      last = num;
    }
  }
  printf("YES\n");
  for (int i = 0; i < N; ++i) {
    printf("%d\n", seq[i]);
  }
  return 0;
}
