#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    string v[n], ans[n];
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    bool good = true;
    string prev = "1000";
    for (int i = 0; i < n; i++) {
      int j;
      ans[i] = v[i];
      for (j = 0; j < 4; j++) {
        string aux = v[i];
        for (int k = '0'; k <= '9'; k++) {
          aux[j] = k;
          if (ans[i] < prev || (aux >= prev && aux < ans[i])) {
            ans[i] = aux;
          }
        }
      }
      if (ans[i] < prev || ans[i] > "2011") {
        good = false;
        break;
      }
      prev = ans[i];
    }
    if (!good) {
      cout << "No solution" << endl;
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}
