#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1007], q, w, pred = 1000, t, qq, i, tt;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  i = 0;
  tt = 1000000;
  q = a[i] / 1000;
  w = a[i] % 1000;
  for (int j = 1; j <= 9; j++) {
    t = j * 1000 + w;
    if (t >= pred && t <= 2011) {
      tt = min(tt, t);
    }
  }
  qq = a[i] / 1000;
  q = a[i] / 100 % 10;
  w = a[i] % 100;
  for (int j = 0; j <= 9; j++) {
    t = qq * 1000 + j * 100 + w;
    if (t >= pred && t <= 2011) {
      tt = min(tt, t);
    }
  }
  qq = a[i] / 100;
  q = a[i] / 10 % 10;
  w = a[i] % 10;
  for (int j = 0; j <= 9; j++) {
    t = qq * 100 + j * 10 + w;
    if (t >= pred && t <= 2011) {
      tt = min(tt, t);
    }
  }
  qq = a[i] / 10;
  q = a[i] % 10;
  for (int j = 0; j <= 9; j++) {
    t = qq * 10 + j;
    if (t >= pred && t <= 2011) {
      tt = min(tt, t);
    }
  }
  if (tt == 1000000 && (a[i] > 2011 || a[i] < 1000)) {
    cout << "No solution";
    return 0;
  } else if (tt != 1000000)
    a[i] = tt;
  pred = a[0];
  for (i = 1; i < n; i++) {
    tt = 1000000;
    q = a[i] / 1000;
    w = a[i] % 1000;
    for (int j = 1; j <= 9; j++) {
      t = j * 1000 + w;
      if (t >= pred && t <= 2011) {
        tt = min(tt, t);
      }
    }
    qq = a[i] / 1000;
    q = a[i] / 100 % 10;
    w = a[i] % 100;
    for (int j = 0; j <= 9; j++) {
      t = qq * 1000 + j * 100 + w;
      if (t >= pred && t <= 2011) {
        tt = min(tt, t);
      }
    }
    qq = a[i] / 100;
    q = a[i] / 10 % 10;
    w = a[i] % 10;
    for (int j = 0; j <= 9; j++) {
      t = qq * 100 + j * 10 + w;
      if (t >= pred && t <= 2011) {
        tt = min(tt, t);
      }
    }
    qq = a[i] / 10;
    q = a[i] % 10;
    for (int j = 0; j <= 9; j++) {
      t = qq * 10 + j;
      if (t >= pred && t <= 2011) {
        tt = min(tt, t);
      }
    }
    if (tt == 1000000 && (a[i] > 2011 || a[i] < 1000)) {
      cout << "No solution";
      return 0;
    } else if (tt != 1000000)
      a[i] = tt;
    pred = a[i];
  }
  for (i = 0; i < n; i++) {
    if (i > 0 && a[i] < a[i - 1]) {
      cout << "No solution";
      return 0;
    }
  }
  for (i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
  return 0;
}
