#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
int diff(int x, int y) {
  int r = 0;
  for (int i = 0; i < 4; i++) {
    if (x % 10 != y % 10) r++;
    x = x / 10;
    y = y / 10;
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  int r[n + 1];
  memset(r, 0, sizeof(r));
  r[0] = 1000;
  int first = 0;
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    first = 0;
    for (int j = r[i - 1]; j <= 2011; j++) {
      first = 0;
      if (diff(j, x) <= 1) {
        first = 1;
        r[i] = j;
        break;
      }
    }
    if (!first) ok = 0;
  }
  if (!ok)
    cout << "No solution\n";
  else {
    for (int i = 1; i <= n; i++) {
      cout << r[i] << "\n";
    }
  }
}
