#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <class _T>
inline istream& operator<<(istream& is, const _T& a) {
  is.putback(a);
  return is;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int n;
int a[1024];
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d", &a[i]);
  }
  int prev = 1000;
  for (int i = 0; i < (int)(n); i++) {
    int x = a[i];
    int b[4];
    for (int j = 0; j < (int)(4); j++) {
      b[j] = x % 10;
      x /= 10;
    }
    int mi = 10000;
    for (int j = 0; j < (int)(4); j++) {
      int d = b[j];
      for (int k = 0; k < (int)(10); k++) {
        b[j] = k;
        int y = 0;
        for (int l = (4) - 1; l >= 0; l--) {
          y = y * 10 + b[l];
        }
        if (y < prev || y > 2011) continue;
        if (y < mi) {
          mi = y;
        }
      }
      b[j] = d;
    }
    if (mi == 10000) {
      puts("No solution");
      return 0;
    }
    a[i] = prev = mi;
  }
  for (int i = 0; i < (int)(n); i++) {
    printf("%d\n", a[i]);
  }
  return 0;
}
