#include <bits/stdc++.h>
using namespace std;
int n;
int ss[1001];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ss[i];
  int prv;
  bool no = false;
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (ss[i] / 1000 >= 2)
        prv = 1000 + ss[i] % 1000;
      else {
        prv = ss[0];
        int j;
        int mul = 1000;
        for (j = 1; j <= 3; j++) {
          mul /= 10;
          if ((ss[i] / mul) % 10 == 0) continue;
          prv = (ss[i] / (mul * 10)) * (mul * 10);
          prv += ss[i] % mul;
          break;
        }
        if (prv >= 2012) {
          no = true;
          break;
        }
      }
    } else {
      int minNum = 1000000000;
      int cand = ss[i];
      int mul = 1;
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 10; k++) {
          int nxt = ss[i] - ((ss[i] / mul) % 10) * mul + k * mul;
          if (nxt - prv >= 0 && minNum > nxt - prv && nxt <= 2011 &&
              nxt >= 1000) {
            cand = nxt;
            minNum = nxt - prv;
          }
        }
        mul *= 10;
      }
      if (cand - prv >= 0 && cand <= 2011 && cand >= 1000) {
        prv = cand;
      } else {
        no = true;
        break;
      }
    }
    res.push_back(prv);
  }
  if (no)
    cout << "No solution" << endl;
  else
    for (int i = 0; i < n; i++) cout << res[i] << endl;
  return 0;
}
