#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:100000000")
int mas[100100];
int get(string &s, string &l, int lst) {
  bool f = true;
  int len = (int)(s).size();
  if (lst == 0) {
    for (int i = 0; i < len; i++) {
      if (s[i] == '?') {
        if (i == 0)
          s[i] = '1';
        else
          s[i] = '0';
      }
    }
    int val = 0;
    for (int i = 0; i < len; i++) val *= 10, val += (s[i] - '0');
    return val;
  }
  for (int i = 0; i < len; i++) {
    if (s[i] == '?') f = false;
  }
  if (f) {
    int val = 0;
    for (int i = 0; i < len; i++) val *= 10, val += (s[i] - '0');
    return val;
  }
  if ((int)(l).size() < (int)(s).size()) {
    for (int i = 0; i < len; i++) {
      if (s[i] == '?') {
        if (i == 0)
          s[i] = '1';
        else
          s[i] = '0';
      }
    }
    int val = 0;
    for (int i = 0; i < len; i++) val *= 10, val += (s[i] - '0');
    return val;
  } else if ((int)(l).size() > (int)(s).size()) {
    return -1;
  } else {
    for (int i = 0; i < len; i++) {
      if (s[i] != '?' && s[i] != l[i]) {
        if (s[i] > l[i]) {
          for (int j = 0; j < i; j++) {
            if (s[j] == '?') s[j] = l[j];
          }
          for (int j = i; j < len; j++) {
            if (s[j] == '?') {
              if (j == 0)
                s[j] = '1';
              else
                s[j] = '0';
            }
          }
          int val = 0;
          for (int k = 0; k < len; k++) val *= 10, val += (s[k] - '0');
          return val;
        } else {
          for (int j = i - 1; j >= 0; j--) {
            if (s[j] == '?' && l[j] != '9') {
              s[j] = (char)(l[j] + 1);
              for (int k = j - 1; k >= 0; k--) {
                s[k] = l[k];
              }
              for (int k = j + 1; k < len; k++) {
                if (s[k] == '?') {
                  if (k == 0)
                    s[k] = '1';
                  else
                    s[k] = '0';
                }
              }
              int val = 0;
              for (int k = 0; k < len; k++) val *= 10, val += (s[k] - '0');
              return val;
            }
          }
          return -1;
        }
      }
    }
    for (int i = len - 1; i >= 0; i--) {
      if (s[i] == '?' && l[i] != '9') {
        s[i] = (char)(l[i] + 1);
        for (int k = i - 1; k >= 0; k--) {
          s[k] = l[k];
        }
        for (int k = i + 1; k < len; k++) {
          if (s[k] == '?') {
            if (k == 0)
              s[k] = '1';
            else
              s[k] = '0';
          }
        }
        int val = 0;
        for (int k = 0; k < len; k++) val *= 10, val += (s[k] - '0');
        return val;
      }
    }
    return -1;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int lst = 0;
  string l;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mas[i] = get(s, l, lst);
    if (mas[i] == -1) {
      printf("NO\n");
      return 0;
    }
    l = s;
    lst = mas[i];
  }
  for (int i = 1; i < n; i++) {
    if (mas[i] <= mas[i - 1]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) printf("%d\n", mas[i]);
  return 0;
}
