#include <bits/stdc++.h>
using namespace std;
int y[1005], print[1005];
int main() {
  int n;
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) scanf("%d ", y + i);
  int j = 0;
  for (int i = 1000; i <= 2011;) {
    int a = i, b = y[j], diff = 0;
    for (int k = 0; k < 4; k++) {
      if (a % 10 != b % 10) diff++;
      a /= 10, b /= 10;
    }
    if (diff < 2)
      print[j++] = i;
    else
      i++;
    if (j == n) {
      for (int k = 0; k < n; k++) printf("%d\n", print[k]);
      return 0;
    }
  }
  puts("No solution");
  return 0;
}
