#include <bits/stdc++.h>
const int N = 1010;
const int inf = 0x3f3f3f3f;
using namespace std;
int dp[N], n, a[N], p[5];
bool check(int a, int b) {
  if (a < b) swap(a, b);
  int ret = 0;
  for (int i = 0; i < 4; i++, a /= 10, b /= 10)
    if ((a % 10) != (b % 10)) ret++;
  return ret <= 1;
}
int main() {
  p[0] = 10;
  for (int i = 1; i < 4; i++) p[i] = p[i - 1] * 10;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 999;
  for (int i = 1; i <= n; i++) {
    for (int j = 1000; j <= 2011; j++) {
      if (!check(a[i], j)) continue;
      if (dp[i - 1] > j) continue;
      dp[i] = j;
      break;
    }
  }
  if (dp[n] == inf)
    puts("No solution");
  else {
    for (int i = 1; i <= n; i++) printf("%d\n", dp[i]);
  }
  return 0;
}
