#include <bits/stdc++.h>
using namespace std;
int n, ans[1010];
char s[1230];
int main() {
  scanf("%d", &n);
  int lp = 1000;
  bool ok = true;
  for (int i = 0; i < (int)(n); i++) {
    scanf("%s", s);
    int mi = 100000, cur;
    for (int q = 0; q < (int)(4); q++) {
      char z = s[q];
      for (int j = 0; j < (int)(10); j++) {
        s[q] = '0' + j;
        sscanf(s, "%d", &cur);
        if (cur >= lp && cur <= 2011 && cur < mi) mi = cur;
      }
      s[q] = z;
    }
    if (mi < 9999) {
      ans[i] = mi;
      lp = mi;
    } else {
      ok = false;
    }
  }
  if (ok) {
    for (int i = 0; i < (int)(n); i++) printf("%d\n", ans[i]);
  } else
    printf("No solution\n");
  return 0;
}
