#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int y[1001];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> y[i];
  int a = n - 1;
  int ans[1001];
  for (int dates = 2011; dates >= 1000; dates--) {
    if (a < 0) break;
    if (dates % 1000 == y[a] % 1000 || dates / 10 == y[a] / 10 ||
        (dates / 1000 == y[a] / 1000 && dates % 100 == y[a] % 100) ||
        (dates / 100 == y[a] / 100 && dates % 10 == y[a] % 10)) {
      ans[a] = dates;
      a--;
      dates++;
    }
  }
  if (a < 0) {
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
  } else
    cout << "No solution";
  return 0;
}
