#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, y[1000], i, z, h[4], m, nabor[100], Nb, j, zz;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> y[i - 1];
  z = 999;
  for (i = 1; i <= n; i++) {
    m = y[i - 1];
    h[3] = m % 10;
    m = m / 10;
    h[2] = m % 10;
    m = m / 10;
    h[1] = m % 10;
    m = m / 10;
    h[0] = m % 10;
    Nb = 0;
    m = y[i - 1];
    for (j = 1; j <= 2; j++) {
      zz = m + (j - h[0]) * 1000;
      if ((zz >= z) && (zz <= 2011)) {
        Nb++;
        nabor[Nb - 1] = zz;
      }
    }
    for (j = 0; j <= 9; j++) {
      zz = m + (j - h[1]) * 100;
      if ((zz >= z) && (zz <= 2011)) {
        Nb++;
        nabor[Nb - 1] = zz;
      }
    }
    for (j = 0; j <= 9; j++) {
      zz = m + (j - h[2]) * 10;
      if ((zz >= z) && (zz <= 2011)) {
        Nb++;
        nabor[Nb - 1] = zz;
      }
    }
    for (j = 0; j <= 9; j++) {
      zz = m + (j - h[3]);
      if ((zz >= z) && (zz <= 2011)) {
        Nb++;
        nabor[Nb - 1] = zz;
      }
    }
    if (Nb == 0) {
      cout << "No solution";
      return 0;
    }
    z = 100000;
    for (j = 1; j <= Nb; j++) z = min(z, nabor[j - 1]);
    y[i - 1] = z;
  }
  for (i = 1; i <= n; i++) cout << y[i - 1] << endl;
  return 0;
}
