#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000];
int can[1000][10000];
vector<int> res;
bool solve(int idx, int mini) {
  if (idx == n) return true;
  if (can[idx][mini] > -1) return can[idx][mini];
  vector<int> dig;
  dig.clear();
  int tmp = a[idx];
  while (tmp > 0) {
    dig.push_back(tmp % 10);
    tmp /= 10;
  }
  reverse(dig.begin(), dig.end());
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 10; ++j) {
      tmp = dig[i];
      dig[i] = j;
      int x = 0;
      for (int k = 0; k < 4; ++k) x = x * 10 + dig[k];
      if (x >= mini && x <= 2011) {
        if (solve(idx + 1, x)) {
          res.push_back(x);
          return can[idx][mini] = 1;
        }
      }
      dig[i] = tmp;
    }
  return can[idx][mini] = 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  res.clear();
  memset(can, -1, sizeof(can));
  if (!solve(0, 1000))
    cout << "No solution" << endl;
  else {
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); ++i) cout << res[i] << endl;
  }
  return 0;
}
