#include <bits/stdc++.h>
using namespace std;
int n;
string a[1111], r[1111];
int main() {
  cin >> n;
  string z = "1000";
  for (int i(0); i < n; ++i) {
    cin >> a[i];
    r[i] = "9999";
    if (a[i] >= z) r[i] = a[i];
    for (int j(0); j < 4; ++j) {
      string v = a[i];
      for (int d(0); d < 10; ++d) {
        v[j] = d + '0';
        if (v >= z && v < r[i]) r[i] = v;
      }
    }
    if (r[i] > "2011") {
      puts("No solution");
      return 0;
    }
    z = r[i];
  }
  for (int i(0); i < n; ++i) cout << r[i] << endl;
  return 0;
}
