#include <bits/stdc++.h>
using namespace std;
char buf[1002][5];
int main() {
  int n, m, i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> buf[i];
  for (i = 0; i < n; i++) {
    string best = "2012";
    for (j = 0; j < 4; j++) {
      for (char t = '0'; t <= '9'; t++) {
        string cur = buf[i];
        cur[j] = t;
        if (cur[0] != '0' && (!i || cur >= buf[i - 1]) && (cur < best)) {
          best = cur;
        }
      }
    }
    if (best != "2012")
      strcpy(buf[i], best.c_str());
    else {
      cout << "No solution\n";
      return 0;
    }
  }
  for (i = 0; i < n; i++) puts(buf[i]);
  return 0;
}
