#include <bits/stdc++.h>
using namespace std;
int shuwei[2][4];
int a[100005];
int b[100005];
int check(int a, int b) {
  int sum = 0;
  shuwei[0][0] = a / 1000;
  shuwei[0][1] = a / 100 % 10;
  shuwei[0][2] = a / 10 % 10;
  shuwei[0][3] = a % 10;
  shuwei[1][0] = b / 1000;
  shuwei[1][1] = b / 100 % 10;
  shuwei[1][2] = b / 10 % 10;
  shuwei[1][3] = b % 10;
  for (int i = 0; i < 4; i++) {
    if (shuwei[0][i] != shuwei[1][i]) sum++;
  }
  if (sum <= 1) return 1;
  return 0;
}
int main() {
  int n;
  int sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int j = 1000;
  for (int i = 0; i < n; i++)
    for (; j < 2012; j++) {
      if (check(j, a[i])) {
        b[sum++] = j;
        break;
      }
    }
  if (sum == n) {
    for (int i = 0; i < n; i++) printf("%d\n", b[i]);
  } else
    printf("No solution\n");
  return 0;
}
