#include <bits/stdc++.h>
using namespace std;
vector<string> sm;
int n, j, u;
string s;
int main() {
  cin >> n;
  sm.push_back("0000");
  for (int i = 1; i <= n; i++) {
    cin >> s;
    string smin = "9999";
    for (j = 0; j < 4; j++)
      for (u = 0; u < 10; u++) {
        string ss = s;
        ss[j] = char(u + 48);
        if (ss >= "1000" && ss <= "2011" && ss < smin && ss >= sm[i - 1])
          smin = ss;
      }
    if (smin == "9999") {
      puts("No solution");
      return 0;
    }
    sm.push_back(smin);
  }
  for (int i = 1; i <= n; i++) cout << sm[i] << endl;
  return 0;
}
