#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << p.first << " " << p.second;
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long int l = v.size();
  for (long long int i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  string arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (long long int i = 1; i < n; i++) {
    if (arr[i].size() < arr[i - 1].size()) {
      cout << "NO\n";
      return 0;
    }
  }
  string ans = "";
  for (long long int i = 0; i < n; i++) {
    if (i == 0) {
      for (long long int j = 0; j < arr[i].size(); j++) {
        if (arr[i][j] == '?') {
          if (j == 0)
            arr[i][j] = '1';
          else
            arr[i][j] = '0';
        }
      }
      ans = arr[i];
    } else {
      if (arr[i].size() > ans.size()) {
        for (long long int j = 0; j < arr[i].size(); j++) {
          if (arr[i][j] == '?') {
            if (j == 0)
              arr[i][j] = '1';
            else
              arr[i][j] = '0';
          }
        }
        ans = arr[i];
        continue;
      }
      long long int flag = -1;
      long long int first = -1;
      bool greater;
      for (long long int j = 0; j < arr[i].size(); j++) {
        if (arr[i][j] == '?') {
          flag = j;
        } else {
          if (arr[i][j] != '?' && arr[i][j] != ans[j]) {
            first = j;
            if (arr[i][j] > ans[j])
              greater = 1;
            else
              greater = 0;
            break;
          }
        }
      }
      if (first == -1) {
        if (flag == -1) {
          cout << "NO\n";
          return 0;
        } else {
          bool mila = 0;
          for (long long int j = flag; j >= 0; j--) {
            if (arr[i][j] == '?') {
              if (mila)
                arr[i][j] = ans[j];
              else {
                if (ans[j] == '9')
                  arr[i][j] = '0';
                else {
                  arr[i][j] = ans[j] + 1;
                  mila = 1;
                }
              }
            }
          }
          if (mila == 0) {
            cout << "NO\n";
            return 0;
          }
        }
      } else {
        if (flag == -1) {
          if (!greater) {
            cout << "NO\n";
            return 0;
          } else {
            for (long long int j = first + 1; j < arr[i].size(); j++) {
              if (arr[i][j] == '?') arr[i][j] = '0';
            }
          }
        } else {
          bool mila = 0;
          if (greater) mila = 1;
          for (long long int j = flag; j >= 0; j--) {
            if (arr[i][j] == '?') {
              if (mila)
                arr[i][j] = ans[j];
              else {
                if (ans[j] == '9')
                  arr[i][j] = '0';
                else {
                  arr[i][j] = ans[j] + 1;
                  mila = 1;
                }
              }
            }
          }
          if (mila == 0) {
            cout << "NO\n";
            return 0;
          }
          for (long long int j = first + 1; j < arr[i].size(); j++) {
            if (arr[i][j] == '?') arr[i][j] = '0';
          }
        }
      }
      ans = arr[i];
    }
  }
  cout << "YES\n";
  for (long long int i = 0; i < n; i++) cout << arr[i] << "\n";
  return 0;
}
