#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
string s[N];
string q[N];
string funk(int x) {
  string ans;
  while (x > 0) {
    ans = char(x % 10 + 48) + ans;
    x /= 10;
  }
  return ans;
}
int main() {
  int n, m, i, j;
  cin >> n;
  for (int i = 1000; i <= 2011; i++) {
    q[i] = funk(i);
  }
  for (i = 1; i <= n; i++) {
    cin >> s[i];
  }
  int id = 1000;
  for (i = 1; i <= n; i++) {
    bool ok = 1;
    for (int k = id; k <= 2011; k++) {
      int cnt = 0;
      for (int j = 0; j < 4; j++) {
        cnt += (s[i][j] != q[k][j]);
      }
      if (cnt <= 1) {
        ok = 0;
        id = k;
        s[i] = q[k];
        break;
      }
    }
    if (ok) {
      puts("No solution");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << s[i] << endl;
  }
}
