#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int inf = (-1u) >> 1;
int a[maxn], n;
int dis(int x, int y, int dep) {
  if (dep == 0) return 0;
  return dis(x / 10, y / 10, --dep) + (x % 10 != y % 10);
}
bool change(int& x, int y) {
  for (int i = (1000); i <= (2011); ++i) {
    if (dis(x, i, 4) <= 1 && i >= y) {
      x = i;
      return true;
    }
  }
  return false;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < (n); ++i) {
      scanf("%d", &a[i]);
    }
    bool f = true;
    for (int i = 0; i < (n); ++i) {
      if (!change(a[i], i ? a[i - 1] : 0)) {
        puts("No solution");
        f = false;
        break;
      }
    }
    if (!f) continue;
    for (int i = 0; i < (n); ++i) {
      printf("%d\n", a[i]);
    }
  }
  return 0;
}
