#include <bits/stdc++.h>
using namespace std;
int x[1000], ans[1000][4][10];
int change(int x, int k, int d) {
  switch (k) {
    case 0:
      return d * 1000 + x % 1000;
    case 1:
      return (x / 1000) * 1000 + d * 100 + x % 100;
    case 2:
      return (x / 100) * 100 + d * 10 + x % 10;
    case 3:
      return (x / 10) * 10 + d;
    default:
      printf("fick");
  };
}
void restore(int n, int k, int e) {
  if (n > 0)
    for (int j = 0; j < 4; ++j)
      for (int d = (j == 0 ? 1 : 0); d < 10; ++d)
        if ((ans[n - 1][j][d]) &&
            (change(x[n], k, e) >= change(x[n - 1], j, d)) &&
            (change(x[n], k, e) <= 2011)) {
          restore(n - 1, j, d);
          printf("%d\n", change(x[n], k, e));
          return;
        }
  printf("%d\n", change(x[n], k, e));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
  for (int j = 0; j < 4; ++j)
    for (int d = (j == 0 ? 1 : 0); d < 10; ++d)
      if (change(x[0], j, d) <= 2011) ans[0][j][d] = true;
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < 4; ++j)
      for (int d = (j == 0 ? 1 : 0); d < 10; ++d)
        if (ans[i - 1][j][d])
          for (int k = 0; k < 4; ++k)
            for (int e = (k == 0 ? 1 : 0); e < 10; ++e)
              if ((change(x[i], k, e) >= change(x[i - 1], j, d)) &&
                  (change(x[i], k, e) <= 2011))
                ans[i][k][e] = true;
  for (int k = 0; k < 4; ++k)
    for (int e = (k == 0 ? 1 : 0); e < 10; ++e)
      if (ans[n - 1][k][e]) {
        restore(n - 1, k, e);
        return 0;
      }
  printf("No solution\n");
  return 0;
}
