#include <bits/stdc++.h>
using namespace std;
char nums[100005][9];
char len[100005];
char last[100005];
int n;
int tens[10];
int wenhao[10];
int comp(int s, int b) {
  if (len[s] > len[b]) return 0;
  if (len[s] < len[b]) return 1;
  int flag = 0;
  for (int i = 0; i <= len[s] - 1; i++) {
    if (nums[b][i] > nums[s][i]) return 1;
    if (nums[b][i] < nums[s][i]) return 0;
    if (nums[b][i] == nums[s][i]) flag++;
  }
  return (flag == (len[s])) ? 0 : 1;
}
int tail(int i, int j) {
  for (int k = j; k <= len[i] - 1; k++) {
    if (nums[i][k] == '?') return 0;
    if (nums[i][k] > nums[i - 1][k]) return 1;
    if (nums[i][k] < nums[i - 1][k]) return 0;
  }
  return 0;
}
int do_delta(int a, int b) {
  int val = 0, val1 = 0;
  int tot = 0;
  for (int i = len[a] - 1; i >= 0; i--) {
    val1 += tens[tot] * (nums[b][i] - '0');
    val += tens[tot++] * ((nums[a][i] == '?') ? 0 : (nums[a][i] - '0'));
  }
  return val - val1;
}
inline int counts(int i) {
  int ret = 0;
  for (int j = 0; j <= len[i] - 1; j++) {
    if (nums[i][j] == '?') ret++, wenhao[ret] = j;
  }
  return ret;
}
int main() {
  tens[0] = 1;
  for (int i = 1; i <= 9; i++) tens[i] = tens[i - 1] * 10;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", nums[i]);
    len[i] = strlen(nums[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= len[i] - 1; j++) {
      if (nums[i][j] == '?') last[i] = j;
    }
    if (i == 1) {
      for (int j = 0; j <= len[i] - 1; j++) {
        if (nums[i][j] == '?') {
          nums[i][j] = j == 0 ? '1' : '0';
        }
      }
      continue;
    }
    if (i == n) {
      for (int j = 0; j <= len[i] - 1; j++) {
        if (nums[i][j] == '?') nums[i][j] = '9';
      }
      if (!comp(i - 1, i)) {
        printf("NO\n");
        exit(0);
      }
      continue;
    }
    if (len[i] > len[i - 1]) {
      for (int j = 0; j <= len[i] - 1; j++) {
        if (nums[i][j] == '?') nums[i][j] = j == 0 ? '1' : '0';
      }
      continue;
    } else if (len[i] < len[i - 1]) {
      printf("NO\n");
      exit(0);
    }
    int delta = do_delta(i, i - 1);
    if (delta > 0) {
      for (int j = 0; j <= len[i] - 1; j++) {
        if (nums[i][j] == '?') nums[i][j] = '0';
      }
      continue;
    }
    delta = -delta;
    int lenx = counts(i);
    int right = tens[lenx] - 1;
    int left = 0;
    int res = -1;
    while (left <= right) {
      int mid = (left + right) >> 1;
      int temp = 0;
      char buf[10] = {'0', '0', '0', '0', '0', '0', '0', '0', '0', 0};
      int ptr = lenx - 1;
      int tmid = mid;
      while (tmid) {
        buf[ptr] = tmid % 10 + '0';
        ptr--;
        tmid /= 10;
      }
      for (int j = 1; j <= lenx; j++) {
        temp += (buf[j - 1] - '0') * tens[len[i] - 1 - wenhao[j]];
      }
      if (delta < temp) {
        res = mid;
        right = mid - 1;
      } else
        left = mid + 1;
    }
    if (res == -1) {
      printf("NO\n");
      exit(0);
    }
    for (int j = len[i] - 1; j >= 0; j--) {
      if (nums[i][j] == '?') {
        nums[i][j] = res % 10 + '0';
        res /= 10;
      }
    }
    if (!comp(i - 1, i)) {
      printf("NO\n");
      exit(0);
    }
    continue;
    int fallback = -1;
    for (int j = 0; j <= len[i] - 1; j++) {
      if (nums[i][j] == '?') {
        if (j == last[i]) {
          if (nums[i - 1][j] == '9') {
            int tm = tail(i, j + 1);
            if (!tm && fallback == -1)
              for (int k = j - 1; k >= 0; k--) {
                if (nums[i][j] == '?' && nums[i - 1][k] != '9') {
                  fallback = -2;
                  nums[i][k] = nums[i - 1][k] + 1;
                }
              }
            if (!tm && fallback == -1) {
              printf("NO\n");
              exit(0);
            }
            if (fallback == -2) {
              nums[i][j] = '0';
              for (int x = j + 1; x <= len[i] - 1; x++) {
                if (nums[i][x] == '?') nums[i][x] = '0';
              }
              break;
            } else {
              nums[i][j] = nums[i - 1][j];
            }
            continue;
          }
          if (fallback != -2) {
            int tm = tail(i, j + 1);
            if (tm) {
              nums[i][j] = nums[i - 1][j];
            }
            nums[i][j] = nums[i - 1][j] + 1;
          } else {
          }
        } else {
          nums[i][j] = nums[i - 1][j];
          continue;
        }
        continue;
      }
      if (nums[i - 1][j] > nums[i][j]) {
        if (fallback == -2) continue;
        for (int k = j - 1; k >= 0; k--) {
          if (nums[i][j] == '?' && nums[i - 1][k] != '9') {
            fallback = -2;
            nums[i][k] = nums[i - 1][k] + 1;
          }
        }
        if (fallback == -1) {
          printf("NO\n");
          exit(0);
        }
        continue;
      }
      if (nums[i][j] > nums[i - 1][j]) fallback = -2;
    }
    if (!comp(i - 1, i)) {
      printf("NO\n");
      exit(0);
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    printf("%s\n", nums[i]);
  }
}
