#include <bits/stdc++.h>
int fx[] = {-1, 0, +1, 0}, fy[] = {0, +1, 0, -1},
    ex[] = {-1, -1, 0, +1, +1, +1, 0, -1},
    ey[] = {0, +1, +1, +1, 0, -1, -1, -1};
using namespace std;
int n;
int a[20000], best[20000];
int T[200];
void nosol() {
  puts("No solution");
  exit(0);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  T[0] = 1;
  T[1] = 10;
  T[2] = 100;
  T[3] = 1000;
  T[4] = 10000;
  for (int i = 0; i < n; i++) {
    best[i] = 9999;
    for (int j = 0, x; j < 4; j++) {
      x = a[i] % T[3 - j] + (a[i] / T[4 - j]) * T[4 - j];
      for (int k = 0; k < 10; k++) {
        if (k || j)
          if (x <= 2011 && x >= 1000) {
            if (!i || x >= best[i - 1]) best[i] = min(best[i], x);
          }
        x += T[3 - j];
      }
    }
    if (best[i] == 9999) nosol();
  }
  for (int i = 1; i < n; i++)
    if (best[i] < best[i - 1]) nosol();
  for (int i = 0; i < n; i++) printf("%d\n", best[i]);
  return 0;
}
