#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long mod = 998244353;
const int phash = 3;
const long long modhash = 1000000000000000003;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> dates(n);
  for (int i = 0; i < n; i++) cin >> dates[i];
  for (int i = 0; i < n; i++) {
    string best = "2012";
    for (int j = 0; j < 4; j++)
      for (char x = '0'; x <= '9'; x++) {
        string cur = dates[i];
        cur[j] = x;
        if (cur[0] != '0' && (!i || cur >= dates[i - 1]) && cur < best)
          best = cur;
      }
    if (best == "2012") {
      cout << "No solution";
      return 0;
    }
    dates[i] = best;
  }
  for (string i : dates) cout << i << '\n';
}
