#include <bits/stdc++.h>
using namespace std;
string s[1111];
string sr[1111];
string f(string a, string prev) {
  string res = a, mn = "9999";
  for (int i = 0; i < 4; i++)
    for (char c = '0'; c <= '9'; c++) {
      res[i] = c;
      if (res >= prev && res < mn && res <= "2011" && res >= "1000") mn = res;
      res[i] = a[i];
    }
  return mn;
}
int main(void) {
  int i, n;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) cin >> s[i];
    sr[0] = f(s[0], "1000");
    for (i = 1; i < n; i++) sr[i] = f(s[i], sr[i - 1]);
    if (sr[n - 1] <= "2011")
      for (i = 0; i < n; i++) cout << sr[i] << '\n';
    else
      printf("No solution\n");
  }
  return 0;
}
