#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
bool checkDiff(int original, int changed) {
  int counter = 0;
  for (int i = 0; i < (int)4; ++i) {
    if (original % 10 != changed % 10) {
      ++counter;
    }
    original /= 10;
    changed /= 10;
  }
  return counter <= 1;
}
int main() {
  std::ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> years;
  for (int n = 0; n < (int)N; ++n) {
    int year;
    cin >> year;
    years.push_back(year);
  }
  vector<int> answers;
  bool ok = true;
  int lastYear = 1000;
  for (int n = 0; n < (int)N; ++n) {
    int nextYear;
    for (nextYear = lastYear; nextYear <= 2011; ++nextYear) {
      if (checkDiff(years[n], nextYear)) {
        break;
      }
    }
    if (nextYear > 2011) {
      ok = false;
      break;
    }
    answers.push_back(nextYear);
    lastYear = nextYear;
  }
  if (!ok) {
    cout << "No solution" << endl;
    return 0;
  }
  for (int n = 0; n < (int)N; ++n) {
    cout << answers[n] << endl;
  }
}
