#include <bits/stdc++.h>
using namespace std;
int n;
string s[1001], lower = "1000", upper = "2011";
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    string S = "9999";
    for (int j = 0; j < 4; j++)
      for (int k = 0; k <= 9; k++) {
        char save = s[i][j];
        s[i][j] = k + '0';
        if (s[i] >= lower) S = min(S, s[i]);
        s[i][j] = save;
      }
    lower = s[i] = S;
  }
  if (s[n] > upper)
    printf("No solution\n");
  else
    for (int i = 1; i <= n; i++) cout << s[i] << endl;
  return 0;
}
