#include <bits/stdc++.h>
using namespace std;
string s[1001];
bool check(string s) {
  int x = 0;
  for (int i = 0; i < (int)s.size(); i++) x = x * 10 + (int)(s[i] - 48);
  return (x >= 1000 && x <= 2011);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
  s[0] = "0000";
  for (int i = 1; i <= n; i++) {
    string cur = "9999";
    for (int j = 0; j < 4; j++) {
      string hold = s[i];
      for (int k = 0; k <= 9; k++) {
        hold[j] = (char)(k + 48);
        if (check(hold) == true && hold >= s[i - 1]) cur = min(cur, hold);
        hold[j] = s[i][j];
      }
    }
    s[i] = cur;
    if (s[i] < s[i - 1] || cur == "9999") {
      puts("No solution");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << s[i] << endl;
  }
}
