#include <bits/stdc++.h>
int n, a[1005], k[5] = {0, 1, 10, 100, 1000};
bool deal(int s) {
  for (int w = 4; w; w--) {
    for (int j = (a[s] / k[w]) % 10; j; j--) {
      int t = a[s] - k[w] * j;
      if (t >= 1000 && t <= 2011 && t >= a[s - 1]) {
        a[s] = t;
        return 1;
      }
    }
  }
  for (int w = 1; w <= 4; w++) {
    for (int j = 0; j <= 9 - (a[s] / k[w]) % 10; j++) {
      int t = a[s] + k[w] * j;
      if (t >= 1000 && t <= 2011 && t >= a[s - 1]) {
        a[s] = t;
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!deal(i)) {
      printf("No solution");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", a[i]);
  return 0;
}
