#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < ((n)); ++i) cin >> a[i];
  vector<int> res;
  for (int i = (0); i < ((n)); ++i) {
    ostringstream oss;
    oss << a[i];
    string str = oss.str();
    vector<int> cur;
    for (int j = (0); j < (((int)str.size())); ++j)
      for (int k = (0); k < ((10)); ++k)
        if (!(j == 0 && k == 0)) {
          string temp = str;
          temp[j] = k + '0';
          int next = atoi(temp.c_str());
          if (next >= 1000 && next <= 2011) cur.push_back(next);
        }
    sort(cur.begin(), cur.end());
    if ((int)res.size() == 0)
      res.push_back(cur[0]);
    else {
      vector<int>::const_iterator it =
          lower_bound(cur.begin(), cur.end(), res.back());
      if (it == cur.end() || *it < res.back()) {
        cout << "No solution\n";
        return 0;
      }
      res.push_back(*it);
    }
  }
  for (int i = (0); i < (((int)res.size())); ++i) {
    cout << res[i] << endl;
  }
  return 0;
}
