#include <bits/stdc++.h>
using namespace std;
int N;
string harry[1000];
vector<string> result;
map<pair<int, string>, int> memo;
bool ron(int idx, string& before) {
  if (idx == N) return true;
  pair<int, string> p = make_pair(idx, before);
  if (memo.find(p) != memo.end()) return memo[p];
  memo[p] = 0;
  for (int i = (0); i < (4); i++) {
    string& t = harry[idx];
    char c = t[i];
    for (int j = (0); j < (10); j++) {
      t[i] = j + '0';
      if (before <= t && t <= "2011") {
        if (ron(idx + 1, t)) {
          result.push_back(t);
          memo[p] = 1;
          return memo[p];
        }
      }
    }
    t[i] = c;
  }
  return false;
}
int main() {
  cin >> N;
  for (int i = (0); i < (N); i++) cin >> harry[i];
  string junk = "1000";
  ron(0, junk);
  reverse((result).begin(), (result).end());
  if (result.size() == 0)
    cout << "No solution" << endl;
  else
    for (int i = (0); i < (N); i++) cout << result[i] << endl;
}
