#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int c[N];
int n;
int num;
int temp;
int tnum;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i];
  tnum = 2011;
  for (int j = 1; j <= 2; j++) {
    num = j * 1000 + ((c[0] / 10) % 10) * 10 + (c[0] % 10) +
          ((c[0] / 100) % 10) * 100;
    tnum = min(tnum, num);
  }
  for (int j = 0; j <= 1; j++) {
    num = (c[0] / 1000) * 1000 + c[0] % 10 + ((c[0] / 10) % 10) * 10 + j * 100;
    tnum = min(tnum, num);
  }
  for (int j = 0; j <= 1; j++) {
    num = (c[0] / 100) * 100 + (c[0] % 10) + j * 10;
    tnum = min(tnum, num);
  }
  for (int j = 0; j <= 1; j++) {
    num = (c[0] / 10) * 10 + j;
    tnum = min(tnum, num);
  }
  c[0] = tnum;
  for (int i = 1; i < n; i++) {
    int ok = 0;
    tnum = 2011;
    for (int j = 1; j <= 2; j++) {
      num = j * 1000 + ((c[i] / 10) % 10) * 10 + (c[i] % 10) +
            ((c[i] / 100) % 10) * 100;
      if (num >= 1000 && num <= 2011 && num >= c[i - 1]) {
        ok = 1;
        tnum = min(tnum, num);
      }
    }
    for (int j = 0; j <= 9; j++) {
      num =
          (c[i] / 1000) * 1000 + c[i] % 10 + ((c[i] / 10) % 10) * 10 + j * 100;
      if (num >= 1000 && num <= 2011 && num >= c[i - 1]) {
        ok = 1;
        tnum = min(tnum, num);
      }
    }
    for (int j = 0; j <= 9; j++) {
      num = (c[i] / 100) * 100 + (c[i] % 10) + j * 10;
      if (num >= 1000 && num <= 2011 && num >= c[i - 1]) {
        ok = 1;
        tnum = min(tnum, num);
      }
    }
    for (int j = 0; j <= 9; j++) {
      num = (c[i] / 10) * 10 + j;
      if (num >= 1000 && num <= 2011 && num >= c[i - 1]) {
        ok = 1;
        tnum = min(tnum, num);
      }
    }
    if (!ok) {
      cout << "No solution" << endl;
      return 0;
    }
    c[i] = tnum;
  }
  for (int i = 0; i < n; i++) cout << c[i] << endl;
  return 0;
}
