#include <bits/stdc++.h>
using namespace std;
int n, p, ans[1000 + 10], a[5], c[5];
int solve(int x, int p) {
  int sol = 10000;
  a[1] = c[1] = x / 1000 % 10;
  a[2] = c[2] = x / 100 % 10;
  a[3] = c[3] = x / 10 % 10;
  a[4] = c[4] = x % 10;
  for (int i = 1; i <= 9; i++) {
    a[1] = i;
    int nr = a[1] * 1000 + a[2] * 100 + a[3] * 10 + a[4];
    if (nr >= 1000 && nr <= 2011 && nr < sol && nr >= p) sol = nr;
  }
  a[1] = c[1];
  for (int i = 2; i <= 4; i++) {
    for (int j = 0; j <= 9; j++) {
      a[i] = j;
      int nr = a[1] * 1000 + a[2] * 100 + a[3] * 10 + a[4];
      if (nr >= 1000 && nr <= 2011 && nr < sol && nr >= p) sol = nr;
    }
    a[i] = c[i];
  }
  if (sol >= 1000 && sol <= 2011 && sol >= p) return sol;
  return -1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    int y = solve(x, p);
    if (y == -1) {
      cout << "No solution" << '\n';
      return 0;
    } else
      ans[i] = y;
    p = y;
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << '\n';
  return 0;
}
