#include <bits/stdc++.h>
int N;
char Nr[101101][10];
int Now[101101];
void INPUT() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%s", Nr[i] + 1);
}
int mypower(int x, int k) {
  int result = 1;
  for (int i = 1; i <= k; i++) result *= x;
  return result;
}
void PROCESS() {
  Now[0] = 0;
  for (int k = 1; k <= N; k++) {
    int p = (int)strlen(Nr[k] + 1);
    if (p < (int)strlen(Nr[k - 1] + 1) && k != 1) {
      printf("NO\n");
      return;
    }
    int power = mypower(10, p - 1);
    int now = 0;
    for (int i = 1; i <= p; i++) {
      if (Nr[k][i] == '?') {
        int nowpower = power / 10;
        int nnow = 0;
        int past = (Now[k - 1] / power) % 10;
        if (past != 0 || i != 1) {
          for (int j = i + 1; j <= p; j++) {
            int kk = Nr[k][j] - '0';
            if (Nr[k][j] == '?') kk = 9;
            nnow += kk * nowpower;
            nowpower /= 10;
          }
          if (Now[k - 1] % power < nnow) {
            now += past * power;
            Nr[k][i] = '0' + past;
          } else {
            now += (past + 1) * power;
            if (past == 9) {
              printf("NO\n");
              return;
            }
            Nr[k][i] = '0' + past + 1;
            if (now > Now[k - 1]) {
              for (int j = i + 1; j <= p; j++) {
                if (Nr[k][j] == '?') Nr[k][j] = '0';
              }
              break;
            }
          }
        } else {
          now += 1 * power;
          Nr[k][i] = '1';
          if (now > Now[k - 1]) {
            for (int j = i + 1; j <= p; j++) {
              if (Nr[k][j] == '?') Nr[k][j] = '0';
            }
            break;
          }
        }
      } else {
        int past = (Now[k - 1] / power) % 10;
        if ((Nr[k][i] - '0') < past) {
          printf("NO\n");
          return;
        }
        now += (Nr[k][i] - '0') * power;
        if (now > Now[k - 1]) {
          for (int j = i + 1; j <= p; j++) {
            if (Nr[k][j] == '?') Nr[k][j] = '0';
          }
          break;
        }
      }
      power /= 10;
    }
    Now[k] = 0;
    for (int i = 1; i <= p; i++) {
      Now[k] *= 10;
      Now[k] += (Nr[k][i] - '0');
    }
    if (Now[k] <= Now[k - 1]) {
      printf("NO\n");
      return;
    }
  }
  printf("YES\n");
  for (int i = 1; i <= N; i++) {
    printf("%s\n", Nr[i] + 1);
  }
}
int main() {
  INPUT();
  PROCESS();
  return 0;
}
