#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
set<pair<int, int> > dp[1005];
vector<int> getOne(int first) {
  vector<int> tmp;
  if (first >= 1000 && first <= 2011) tmp.push_back(first);
  string str = to_string(first);
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 10; j++) {
      if (i + j == 0) continue;
      string now = str;
      now[i] = '0' + j;
      int val = stoi(now);
      if (val >= 1000 && val <= 2011) tmp.push_back(val);
    }
  }
  return tmp;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    int first;
    scanf("%d", &first);
    arr.push_back(first);
  }
  vector<int> start = getOne(arr[0]);
  for (int first : start) {
    dp[0].insert({first, -1});
  }
  for (int i = 1; i < n; i++) {
    start = getOne(arr[i]);
    for (int first : start) {
      for (auto pr : dp[i - 1]) {
        if (first >= pr.first) {
          dp[i].insert({first, pr.first});
          break;
        }
      }
    }
  }
  if (dp[n - 1].empty()) {
    puts("No solution");
    return 0;
  }
  vector<int> ans;
  pair<int, int> pr = *dp[n - 1].begin();
  ans.push_back(pr.first);
  for (int i = n - 2; i >= 0; i--) {
    pair<int, int> pr = *dp[i].lower_bound((pair<int, int>){pr.second, -100});
    ans.push_back(pr.first);
  }
  for (int i = n - 1; i >= 0; i--) {
    printf("%d\n", ans[i]);
  }
}
