#include <bits/stdc++.h>
using namespace std;
bool debug = false;
void print(const vector<int> &a) {
  for (auto v : a) {
    cout << "," << v;
  }
}
long long ten(long long a) {
  long long ret = 1;
  for (long long i = 0; i < a; ++i) {
    ret *= 10;
  }
  return ret;
}
long long min(const vector<int> &a, long long n) {
  if (n >= a.size()) return 0L;
  long long ret = (a[n] == 10 ? (n == 0 ? 1 : 0) : a[n]);
  for (int i = n + 1; i < a.size(); ++i) {
    ret *= 10;
    ret += a[i] == 10 ? 0 : a[i];
  }
  return ret;
}
long long find(const vector<int> &a, const vector<int> &b, int n) {
  if (n >= a.size() || a.size() < b.size() ||
      (a.size() == b.size() && a[n] < b[n])) {
    return -1;
  }
  if (a.size() > b.size()) return min(a, n);
  long long t = ten(a.size() - n - 1);
  if (a[n] != 10) {
    if (a[n] == b[n]) {
      long long ret = find(a, b, n + 1);
      ret = ret < 0 ? ret : ret + t * a[n];
      return ret;
    } else if (a[n] > b[n]) {
      return min(a, n + 1) + t * a[n];
    } else {
      return -1;
    }
  } else {
    if (n == a.size() - 1) {
      if (b[n] == 9) {
        return -1;
      } else {
        return b[n] + 1;
      }
    }
    long long ret = find(a, b, n + 1);
    if (ret > 0) {
      return b[n] * t + ret;
    } else {
      if (b[n] == 9) {
        return -1;
      } else {
        return (b[n] + 1) * t + min(a, n + 1);
      }
    }
  }
}
long long find(const vector<int> &a, long long num) {
  vector<int> b;
  while (num > 0) {
    b.push_back(num % 10);
    num /= 10;
  }
  vector<int> c(b.rbegin(), b.rend());
  return find(a, c, 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(15);
  int n;
  cin >> n;
  vector<vector<int>> a(n);
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == '?') {
        a[i].push_back(10);
      } else {
        a[i].push_back(s[j] - '0');
      }
    }
  }
  vector<long long> res(n);
  res[0] = min(a[0], 0);
  for (int i = 1; i < n; ++i) {
    res[i] = find(a[i], res[i - 1]);
    if (res[i] < 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    cout << res[i] << "\n";
  }
  return 0;
}
