#include <bits/stdc++.h>
using namespace std;
string A, B;
int used[10][2];
int memo[10][2];
int m;
int dp(int pos, int mayor) {
  if (pos == m) return mayor;
  if (used[pos][mayor]) return memo[pos][mayor];
  used[pos][mayor] = 1;
  int &dev = memo[pos][mayor] = 0;
  if (B[pos] == '?') {
    if (mayor) {
      if (pos == 0) {
        dev = dp(pos + 1, 1);
      } else {
        dev = dp(pos + 1, 1);
      }
    } else {
      for (int c = A[pos]; c <= '9'; ++c) {
        if (pos == 0 && c == '0') continue;
        dev |= dp(pos + 1, c > A[pos]);
      }
    }
  } else {
    if (!mayor && B[pos] < A[pos])
      return 0;
    else
      dev = dp(pos + 1, mayor ? 1 : (B[pos] > A[pos]));
  }
  return dev;
}
string rec(int pos, int mayor) {
  if (pos == m) return "";
  if (B[pos] == '?') {
    if (mayor) {
      if (pos == 0) {
        return string(1, '1') + rec(pos + 1, 1);
      } else {
        return string(1, '0') + rec(pos + 1, 1);
      }
    } else {
      for (int c = A[pos]; c <= '9'; ++c) {
        if (pos == 0 && c == '0') continue;
        if (dp(pos + 1, c > A[pos]))
          return string(1, c) + rec(pos + 1, c > A[pos]);
      }
    }
  } else {
    return string(1, B[pos]) + rec(pos + 1, mayor ? 1 : (B[pos] > A[pos]));
  }
}
int toi(string &s) {
  istringstream in(s);
  int x;
  in >> x;
  return x;
}
string tos(int x) {
  ostringstream out;
  out << x;
  return out.str();
}
string S[100000 + 5];
void fix(string &s) {
  for (int i = 0; i < ((int)(s).size()); ++i) {
    if (s[i] == '?') {
      if (i == 0)
        s[i] = '1';
      else
        s[i] = '0';
    }
  }
}
bool f(string &s, string &t) {
  if (((int)(s).size()) > ((int)(t).size())) return 0;
  for (int i = 0; i < ((int)(s).size()); ++i)
    if (s[i] == '?') return 0;
  if (((int)(s).size()) < ((int)(t).size())) {
    fix(t);
    return 1;
  }
  memset(used, 0, sizeof(used));
  m = ((int)(s).size());
  A = s, B = t;
  if (!dp(0, 0)) return 0;
  string C = rec(0, 0);
  t = C;
  return 1;
}
int main() {
  ios_base ::sync_with_stdio(0);
  int n;
  while (cin >> n) {
    S[0] = "";
    bool possible = 1;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      bool ok = f(S[i], s);
      if (!ok) possible = 0;
      S[i + 1] = s;
    }
    if (!possible)
      cout << "NO" << '\n';
    else {
      cout << "YES" << '\n';
      for (int i = 0; i < n; ++i) cout << S[i + 1] << '\n';
    }
  }
}
