#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int findMin(int idx) {
  char s[5];
  int x = a[idx];
  int k = 0;
  while (x > 0) {
    s[k++] = x % 10 + '0';
    x /= 10;
  }
  reverse(s, s + k);
  s[k] = 0;
  vector<int> ret;
  for (int j = 0; j < 4; j++) {
    char t = s[j];
    for (int i = '0'; i <= '9'; i++) {
      s[j] = i;
      x = atoi(s);
      if (x < 1000 || x > 2011) continue;
      if (idx > 0 && x < a[idx - 1]) continue;
      ret.push_back(x);
    }
    s[j] = t;
  }
  if (ret.size() == 0) return -1;
  sort((ret).begin(), (ret).end());
  return ret[0];
}
int main() {
  int n;
  cin >> n;
  a.resize(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  for (int(i) = 0; (i) < (n); (i)++) {
    int x = findMin(i);
    if (x == -1) {
      cout << "No solution\n";
      return 0;
    }
    a[i] = x;
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    cout << a[i] << endl;
  }
}
