#include <bits/stdc++.h>
using namespace std;
int mul[4] = {1, 10, 100, 1000};
int change(int x, int limit) {
  int t = x;
  int digi[4];
  for (int i = 0; i < 4; i++) {
    digi[i] = t % 10;
    t /= 10;
  }
  int ret = 10000;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 10; j++) {
      int u = x - digi[i] * mul[i] + j * mul[i];
      if (u >= limit) ret = min(ret, u);
    }
  return ret;
}
int ans[1001];
int main() {
  int n;
  while (cin >> n) {
    ans[0] = 1000;
    for (int i = 1; i <= n; i++) {
      cin >> ans[i];
      ans[i] = change(ans[i], ans[i - 1]);
    }
    if (ans[n] > 2011)
      cout << "No solution" << endl;
    else {
      for (int i = 1; i <= n; i++) cout << ans[i] << endl;
    }
  }
  return 0;
}
