#include <bits/stdc++.h>
using namespace std;
bool match(const string& prev, string& cur) {
  bool ok = false;
  string minv = "999999";
  for (int i = 0; i < int(cur.length()); i++)
    for (int j = 0; j < int(10); j++) {
      if (i == 0 && j == 0) continue;
      string t = cur;
      t[i] = '0' + j;
      if (t >= prev && t < minv) {
        ok = true;
        minv = t;
      }
    }
  cur = minv;
  return ok;
}
int main() {
  int n;
  cin >> n;
  vector<string> d(n);
  for (int i = 0; i < int(n); i++) cin >> d[i];
  string p = "0000";
  for (int i = 0; i < int(n); i++) {
    if (!match(p, d[i])) {
      cout << "No solution" << endl;
      return 0;
    }
    if (d[i] > "2011") {
      cout << "No solution" << endl;
      return 0;
    }
    p = d[i];
  }
  for (int i = 0; i < int(n); i++) cout << d[i] << endl;
  return 0;
}
