#include <bits/stdc++.h>
using namespace std;
string p[1024];
void gen() {
  int i;
  char c[5];
  for (i = 1000; i < 2012; i++) {
    int m = i;
    c[3] = m % 10 + '0', m /= 10;
    c[2] = m % 10 + '0', m /= 10;
    c[1] = m % 10 + '0', m /= 10;
    c[0] = m % 10 + '0', m /= 10;
    c[4] = '\0';
    p[i - 1000] = string(c);
  }
}
int diff(string s, string t) {
  int cnt = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] != t[i]) cnt++;
  return cnt;
}
int main() {
  int n, i, j;
  string s[1024];
  gen();
  cin >> n;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    for (j = 0; j < 1012; j++)
      if (diff(p[j], s[i]) <= 1 && (i == 0 || (p[j] >= s[i - 1]))) {
        s[i] = p[j];
        break;
      }
    if (j == 1012) {
      cout << "No solution" << endl;
      return 0;
    }
  }
  for (i = 0; i < n; i++) cout << s[i] << endl;
  return 0;
}
