#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) {
  return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y)));
}
double SQSUM(double x, double y) { return x * x + y * y; }
template <class T>
bool INRANGE(T x, T a, T b) {
  return a <= x && x <= b;
}
int func(int a, int max);
int main() {
  int N;
  while (scanf("%d ", &N) != EOF) {
    vector<int> vi;
    for (int n = 0; n < N; n++) {
      int a;
      scanf("%d ", &a);
      vi.push_back(a);
    }
    int hi = 2011;
    for (int i = N - 1; i >= 0; i--) {
      vi[i] = func(vi[i], hi);
      if (vi[i] < 1000) {
        printf("No solution\n");
        return 0;
      }
      hi = vi[i];
    }
    for (int i = 0; i < N; i++) {
      printf("%d\n", vi[i]);
    }
  }
  return 0;
}
int func(int a, int max) {
  int i;
  for (i = max; i >= 1000; i--) {
    int ta = a;
    int ti = i;
    int diff = 0;
    while (ti) {
      if (ti % 10 != ta % 10) {
        diff++;
      }
      ta /= 10;
      ti /= 10;
    }
    if (diff <= 1) {
      return i;
    }
  }
  return -1;
}
