#include <bits/stdc++.h>
const int maxn = 1010;
int dp[maxn][maxn * 2], pnt[maxn][maxn * 2], data[maxn], path[maxn], n;
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &data[i]);
}
int convert(int key, int pos, int num) {
  int tmp[4], t = 0, ret = 0;
  while (t < 4) {
    if (t == pos)
      tmp[t++] = num;
    else
      tmp[t++] = key % 10;
    key /= 10;
  }
  for (int i = 4; i > 0; i--) ret = ret * 10 + tmp[i - 1];
  return ret;
}
void work() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      for (int h = 0; h < 10; h++) {
        int t = convert(data[i], j, h);
        if (t < 1000 || t > 2011) continue;
        if (!i)
          dp[i][t] = 1;
        else {
          for (int k = 1000; k <= t; k++) {
            if (dp[i - 1][k]) {
              dp[i][t] = 1;
              pnt[i][t] = k;
              break;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1000; i < 2012; i++) {
    if (dp[n - 1][i]) {
      ans = i;
      break;
    }
  }
  if (ans) {
    int x = ans, t = n - 1;
    while (x) {
      path[++path[0]] = x;
      x = pnt[t--][x];
    }
    for (int i = path[0]; i > 0; i--) printf("%d\n", path[i]);
  } else
    printf("No solution\n");
}
int main() {
  init();
  work();
  return 0;
}
