#include <bits/stdc++.h>
using namespace std;
string s[1010];
int make(int idx, int val) {
  int i, j, nowval, dif = 100000, pre;
  int ret;
  string st = "", mn = "";
  pre = -1;
  for (i = 0; i < 4; i++) {
    for (j = '0'; j <= '9'; j++) {
      st = s[idx];
      st[i] = j;
      sscanf(st.c_str(), "%d", &nowval);
      if (nowval >= val && nowval <= 2011) {
        if (dif > (nowval - pre)) {
          dif = (nowval - pre);
          mn = st;
        }
      }
    }
  }
  s[idx] = mn;
  sscanf(mn.c_str(), "%d", &ret);
  return ret;
}
int main() {
  int i, j, n, pre;
  while (scanf("%d", &n) == 1) {
    pre = 1000;
    for (i = 0; i < n; i++) {
      cin >> s[i];
      pre = make(i, pre);
    }
    string x, y;
    x = "1000";
    y = "2011";
    int ok = 1;
    for (i = 0; i < n; i++) {
      if (s[i] >= x && s[i] <= y) {
        continue;
      } else {
        ok = 0;
      }
    }
    for (i = 1; i < n; i++) {
      if (s[i] >= s[i - 1]) {
        continue;
      } else {
        ok = 0;
      }
    }
    if (!ok) {
      printf("No solution\n");
    } else {
      for (i = 0; i < n; i++) {
        cout << s[i] << endl;
      }
    }
  }
  return 0;
}
