#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4786)
vector<string> now, inp;
string res[1010];
int main() {
  int n;
  while (cin >> n) {
    inp.clear();
    int i;
    string p;
    for (i = 0; i < n; i++) cin >> p, inp.push_back(p);
    string mx = "2011";
    string mn = "1000";
    int k, j;
    for (k = n - 1; k >= 0; k--) {
      string mx1 = mx;
      if (k < n - 1) mx1 = res[k + 1];
      now.clear();
      for (i = 0; i < 4; i++)
        for (j = '0'; j <= '9'; j++) {
          string tmp = inp[k];
          tmp[i] = j;
          if (tmp >= mn && tmp <= mx1) now.push_back(tmp);
        }
      sort(now.begin(), now.end());
      if (now.size() == 0) break;
      res[k] = now[now.size() - 1];
    }
    if (k >= 0)
      cout << "No solution" << endl;
    else
      for (i = 0; i < n; i++) cout << res[i] << endl;
  }
  return 0;
}
