#include <bits/stdc++.h>
using namespace std;
string find(string s1, string s2, int size1, int size2) {
  if (size1 > size2) {
    for (int i = 0; i < size1; i++) {
      if (i == 0 && s1[i] == '?') {
        s1[i] = '1';
      } else if (s1[i] == '?') {
        s1[i] = '0';
      }
    }
    return s1;
  }
  int j = -1;
  int g = 0;
  int size = size1;
  vector<int> p;
  int ss = 0;
  if (s1[size - 1] == '?') {
    p.push_back(size - 1);
    ss++;
    if (s2[size - 1] == '9') {
      g = 1;
    } else {
      g = 0;
      j = size - 1;
    }
  } else {
    if (s1[size - 1] > s2[size - 1]) {
      g = 0;
      j = size - 1;
    } else {
      g = 1;
    }
  }
  for (int i = size - 2; i >= 0; i--) {
    if (s1[i] == '?') {
      p.push_back(i);
      ss++;
      if (g == 0) {
        g = 0;
      } else {
        if (s2[i] == '9') {
          g = 1;
        } else {
          j = i;
          g = 0;
        }
      }
    } else {
      if (s1[i] > s2[i]) {
        g = 0;
        j = i;
      } else if (s1[i] < s2[i]) {
        g = 1;
      }
    }
  }
  if (g == 1) {
    return "NO";
  }
  if (s1[j] != '?') {
    for (int i = 0; i < ss; i++) {
      if (p[i] > j) {
        s1[p[i]] = '0';
      } else {
        s1[p[i]] = s2[p[i]];
      }
    }
    return s1;
  }
  for (int i = 0; i < ss; i++) {
    if (p[i] == j) {
      s1[p[i]] = s2[p[i]] + 1;
    } else if (p[i] > j) {
      s1[p[i]] = '0';
    } else {
      s1[p[i]] = s2[p[i]];
    }
  }
  return s1;
}
int main() {
  int n;
  cin >> n;
  string s[n];
  int size[n];
  int f = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    size[i] = s[i].size();
    if (i > 0) {
      if (size[i] < size[i - 1]) {
        f = 1;
      }
    }
  }
  if (f == 0) {
    for (int i = 0; i < size[0]; i++) {
      if (i == 0 && s[0][i] == '?') {
        s[0][i] = '1';
      } else if (s[0][i] == '?') {
        s[0][i] = '0';
      }
    }
    for (int i = 1; i < n; i++) {
      string ss = find(s[i], s[i - 1], size[i], size[i - 1]);
      if (ss == "NO") {
        cout << "NO" << endl;
        f = 1;
        break;
      } else {
        s[i] = ss;
      }
    }
    if (f == 0) {
      cout << "YES" << endl;
      for (int i = 0; i < n; i++) {
        cout << s[i] << endl;
      }
    }
  } else {
    cout << "NO" << endl;
  }
}
