#include <bits/stdc++.h>
using namespace std;
void fix(string &s) {
  if (s[0] == '?') {
    s[0] = '1';
  }
  for (auto &i : s) {
    if (i == '?') {
      i = '0';
    }
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (auto &i : a) {
    cin >> i;
  }
  bool ok = true;
  fix(a[0]);
  for (int i = 1; i < n; i++) {
    if (a[i].length() < a[i - 1].length()) {
      ok = false;
      break;
    } else if (a[i].length() > a[i - 1].length()) {
      fix(a[i]);
    } else {
      bool less = false;
      bool eq = true;
      int pos = -1;
      for (int j = 0; j < (int)a[i].length(); j++) {
        if (a[i][j] != '?' && a[i][j] < a[i - 1][j] && eq) {
          less = true;
          if (pos == -1) {
            pos = j;
          }
        }
        if (a[i][j] != '?' && a[i][j] > a[i - 1][j] && eq) {
          if (pos == -1) {
            pos = j;
          }
        }
        if (a[i][j] != '?' && a[i][j] != a[i - 1][j]) {
          eq = false;
        }
      }
      if (less) {
        bool done = false;
        for (int j = (int)a[i].length() - 1; j >= 0; j--) {
          if (a[i][j] == '?') {
            if (j < pos) {
              if (!done) {
                if (a[i - 1][j] == '9') {
                  a[i][j] = '0';
                } else {
                  a[i][j] = a[i - 1][j] + 1;
                  done = true;
                }
              } else {
                a[i][j] = a[i - 1][j];
              }
            } else {
              a[i][j] = '0';
            }
          }
        }
        ok &= done;
      } else if (eq) {
        assert(pos == -1);
        for (int j = (int)a[i].length() - 1; j >= 0; j--) {
          if (a[i][j] == '?' && a[i - 1][j] != '9') {
            pos = j;
            break;
          }
        }
        for (int j = (int)a[i].length() - 1; j >= 0; j--) {
          if (a[i][j] == '?') {
            if (j > pos) {
              a[i][j] = '0';
            } else if (j < pos) {
              a[i][j] = a[i - 1][j];
            } else {
              a[i][j] = a[i - 1][j] + 1;
            }
          }
        }
        ok &= pos != -1;
      } else {
        for (int j = 0; j < (int)a[i].length(); j++) {
          if (a[i][j] == '?') {
            if (j > pos) {
              a[i][j] = '0';
            } else {
              a[i][j] = a[i - 1][j];
            }
          }
        }
      }
    }
  }
  if (ok) {
    cout << "YES" << endl;
    for (auto &i : a) {
      cout << i << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
