#include <bits/stdc++.h>
using namespace std;
bool check[2012][1000] = {false};
bool tr(int m, int n) {
  int t = 0;
  for (int i = 0; i < 4; i++) {
    if (m - 10 * (m / 10) != n - 10 * (n / 10)) t++;
    m /= 10;
    n /= 10;
  }
  if (t <= 1) return true;
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1000; i <= 2011; i++) {
    for (int j = 0; j < n; j++) {
      if (tr(i, a[j])) check[i][j] = true;
    }
  }
  vector<int> ans(n + 1);
  ans[0] = 0;
  for (int i = 1; i <= n; i++) {
    bool flag = false;
    for (int j = 1000; j <= 2011; j++) {
      if (check[j][i - 1] && j >= ans[i - 1]) {
        ans[i] = j;
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << "No solution" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
