#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<string> v(n + 1);
  v[0] = "1000";
  bool ok = true;
  for (int i = 1; i <= n; ++i) {
    string str;
    cin >> str;
    v[i] = "9999";
    for (int j = 0; j < 4; ++j) {
      string str_next = str;
      for (char c = '0'; c <= '9'; ++c) {
        str_next[j] = c;
        if (str_next >= v[i - 1] and v[i] > str_next) v[i] = str_next;
      }
    }
    if (v[i] > "2011") ok = false;
  }
  if (ok)
    for (int i = 1; i <= n; ++i) cout << v[i] << endl;
  else
    cout << "No solution" << endl;
}
