#include <bits/stdc++.h>
using namespace std;
int num(int n, int j, int k) { return (n + (k - (n / j) % 10) * j); }
int main() {
  int n, a[1001], prev;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  a[n] = 2011;
  for (int i = n - 1; i >= 0; i--) {
    prev = a[i];
    for (int j = 1; j < 1001; j *= 10)
      for (int k = 0; k < 10; k++)
        if (!(k > 2 && j == 1000))
          if (num(a[i], j, k) <= a[i + 1] &&
              (prev < num(a[i], j, k) || prev > a[i + 1]))
            prev = num(a[i], j, k);
    if (prev < 1000) {
      cout << "No solution";
      return 0;
    }
    a[i] = prev;
  }
  if (a[0] < 1000)
    cout << "No solution";
  else
    for (int i = 0; i < n; i++) cout << a[i] << endl;
  return 0;
}
