#include <bits/stdc++.h>
using namespace std;
string s[1000 + 10];
string to(int t) {
  string res = "";
  for (; t; t /= 10) res.push_back(t % 10 + '0');
  reverse(res.begin(), res.end());
  return res;
}
int dis(string s1, string s2) {
  int cnt = 0;
  for (int i = 0; i < 4; ++i) cnt += (s1[i] != s2[i]);
  return cnt;
}
void chg(int now) {
  int bd = 0;
  for (int i = 0; i < 4; ++i) {
    bd = bd * 10 + s[now - 1][i] - '0';
  }
  for (int i = bd; i <= 5000; ++i) {
    if (dis(s[now], to(i)) <= 1) {
      s[now] = to(i);
      return;
    }
  }
  s[now] = "5000";
}
int main() {
  s[0] = "1000";
  int n;
  for (; 1 == scanf("%d", &n);) {
    for (int i = 1; i <= n; ++i) cin >> s[i];
    for (int i = 1; i <= n; ++i) {
      chg(i);
    }
    if (s[n] > "2011") {
      cout << "No solution" << endl;
    } else {
      for (int i = 1; i <= n; ++i) {
        cout << s[i] << endl;
      }
    }
  }
  return 0;
}
