#include <bits/stdc++.h>
using namespace std;
vector<int> vec[10000];
int a[210000], b[210000];
void inin() {
  for (int i = 1000; i <= 9999; i++) {
    int x = i;
    int p = x / 10 * 10;
    for (int j = 0; j <= 9; j++) {
      if (p + j >= 1000 && p + j <= 2011) vec[i].push_back(p + j);
    }
    p = x / 100 * 100 + x % 10;
    for (int j = 0; j <= 9; j++) {
      if (p + j * 10 >= 1000 && p + j * 10 <= 2011)
        vec[i].push_back(p + j * 10);
    }
    p = x / 1000 * 1000 + x % 100;
    for (int j = 0; j <= 9; j++) {
      if (p + j * 100 >= 1000 && p + j * 100 <= 2011)
        vec[i].push_back(p + j * 100);
    }
    p = x / 10000 * 10000 + x % 1000;
    for (int j = 0; j <= 9; j++) {
      if (p + j * 1000 >= 1000 && p + j * 1000 <= 2011)
        vec[i].push_back(p + j * 1000);
    }
  }
}
void solve() {
  for (int i = 1000; i <= 9999; i++) vec[i].clear();
  inin();
  for (int i = 1000; i <= 9999; i++) sort(vec[i].begin(), vec[i].end());
  int n;
  scanf("%d", &n);
  int o = -1, ff = 1, l = 0;
  for (int i = 0; i < n; i++) {
    int v, f = 0;
    scanf("%d", &v);
    if (ff) {
      for (int j = 0; j < vec[v].size(); j++)
        if (vec[v][j] >= 1000 && vec[v][j] <= 2011 && vec[v][j] >= o) {
          o = vec[v][j];
          b[l++] = o;
          f = 1;
          break;
        }
      if (f == 0) ff = 0;
    }
  }
  if (!ff)
    printf("No solution\n");
  else {
    for (int i = 0; i < l; i++) {
      printf("%d\n", b[i]);
    }
  }
}
int main() { solve(); }
