#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int res;
  scanf("%d", &res);
  return res;
}
const int N = 100000;
char c[N + 1][10];
int len[N + 1];
int ans[N + 1];
int pw[10];
int getNum(int pos) {
  vector<int> q;
  for (int i = 0; i < len[pos]; ++i) {
    if (c[pos][i] == '?') {
      q.push_back(i);
    }
  }
  if (q.empty()) {
    int ret = atoi(c[pos]);
    if (ret <= ans[pos - 1]) {
      return -1;
    }
    return ret;
  }
  int l = 0, r = pw[q.size()] - 1;
  if (q[0] == 0) {
    l = pw[(int)q.size() - 1];
  }
  while (l < r) {
    int m = (l + r) >> 1;
    int xx = m;
    for (int i = (int)q.size() - 1; i >= 0; --i) {
      c[pos][q[i]] = xx % 10 + '0';
      xx /= 10;
    }
    int val = atoi(c[pos]);
    if (val <= ans[pos - 1]) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  int xx = l;
  for (int i = (int)q.size() - 1; i >= 0; --i) {
    c[pos][q[i]] = xx % 10 + '0';
    xx /= 10;
  }
  int val = atoi(c[pos]);
  if (val <= ans[pos - 1]) {
    return -1;
  } else {
    return val;
  }
}
inline void solve() {
  int n = nxt();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", c[i]);
    len[i] = strlen(c[i]);
  }
  pw[0] = 1;
  for (int i = 1; i < 10; ++i) {
    pw[i] = pw[i - 1] * 10;
  }
  ans[0] = 0;
  for (int i = 1; i <= n; ++i) {
    ans[i] = getNum(i);
    if (ans[i] == -1) {
      puts("NO");
      return;
    }
  }
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    printf("%d\n", ans[i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
