#include <bits/stdc++.h>
using namespace std;
char s[100005][10];
int main() {
  int n;
  int i, j, k;
  int flag;
  while (scanf("%d", &n) != EOF) {
    flag = 1;
    for (i = 1; i <= n; i++) scanf("%s", s[i]);
    for (j = 0; j < strlen(s[1]); j++) {
      if (s[1][j] == '?' && j == 0) s[1][j] = '1';
      if (s[1][j] == '?' && j != 0) s[1][j] = '0';
    }
    for (i = 2; i <= n; i++) {
      int l1, l2, pos, flag1;
      l1 = strlen(s[i - 1]);
      l2 = strlen(s[i]);
      flag1 = 3;
      if (l1 == l2) {
        for (j = 0; j < l1; j++) {
          if (s[i][j] != '?') {
            if (s[i][j] > s[i - 1][j]) {
              flag1 = 2;
              pos = j;
              break;
            }
            if (s[i][j] < s[i - 1][j]) {
              flag1 = 1;
              pos = j;
              break;
            }
          }
        }
        if (flag1 == 2) {
          for (j = 0; j < pos; j++)
            if (s[i][j] == '?') s[i][j] = s[i - 1][j];
          for (j = pos + 1; j < l1; j++)
            if (s[i][j] == '?') s[i][j] = '0';
        }
        if (flag1 == 1) {
          int a = 0;
          for (j = pos - 1; j >= 0; j--) {
            if (s[i][j] == '?' && s[i - 1][j] != '9') {
              s[i][j] = s[i - 1][j] + 1;
              a = 1;
              break;
            }
          }
          if (a == 0) {
            flag = 0;
            goto loop;
          } else {
            for (k = 0; k < j; k++)
              if (s[i][k] == '?') s[i][k] = s[i - 1][k];
            for (k = j + 1; k < l1; k++)
              if (s[i][k] == '?') s[i][k] = '0';
          }
        }
        if (flag1 == 3) {
          int b = 0;
          for (j = l1 - 1; j >= 0; j--)
            if (s[i][j] == '?' && s[i - 1][j] != '9') {
              s[i][j] = s[i - 1][j] + 1;
              b = 1;
              break;
            }
          if (b == 0) {
            flag = 0;
            goto loop;
          } else {
            for (k = 0; k < j; k++)
              if (s[i][k] == '?') s[i][k] = s[i - 1][k];
            for (k = j + 1; k < l1; k++)
              if (s[i][k] == '?') s[i][k] = '0';
          }
        }
      }
      if (l1 > l2) {
        flag = 0;
        goto loop;
      }
      if (l2 > l1) {
        for (j = 0; j < l2; j++) {
          if (s[i][j] == '?' && j == 0) s[i][j] = '1';
          if (s[i][j] == '?' && j != 0) s[i][j] = '0';
        }
      }
    }
  loop:
    if (flag == 0)
      printf("NO\n");
    else {
      printf("YES\n");
      for (i = 1; i <= n; i++) printf("%s\n", s[i]);
    }
  }
}
