#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string arr[n], mx = "2011";
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int p = n - 1; p >= 0; p--) {
    string maxi = "0000";
    for (int i = 0; i <= 3; i++) {
      char s = arr[p][i];
      for (int j = 9; j >= 0; j--) {
        arr[p][i] = char('0' + j);
        if (arr[p] <= mx && arr[p] >= "1000") {
          if (arr[p] > maxi) maxi = arr[p];
        }
      }
      arr[p][i] = s;
    }
    if (maxi == "0000") {
      cout << "No solution" << endl;
      return 0;
    }
    arr[p] = maxi;
    mx = maxi;
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << endl;
  }
}
