#include <bits/stdc++.h>
using namespace std;
int n, y[1010], z;
int naym(int a, int b) {
  int r = 10000, t;
  int c[4], d[4];
  for (int i = 0; i < 4; ++i) {
    c[i] = a % 10;
    a /= 10;
    d[i] = c[i];
  }
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 10; ++j)
      if (i != 3 || j != 0) {
        d[i] = j;
        t = 0;
        for (int k = 3; k >= 0; --k) t = t * 10 + d[k];
        if (t >= b) {
          if (t < r) r = t;
        }
        d[i] = c[i];
      }
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &y[i]);
  z = 0;
  for (int i = 0; i < n; ++i) {
    y[i] = naym(y[i], z);
    z = y[i];
    if (y[i] > 2011) {
      printf("No solution\n");
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) printf("%d\n", y[i]);
  return 0;
}
