#include <bits/stdc++.h>
using namespace std;
int check(int n1, int n2) {
  int a1[10], a2[10], c1 = 0, c2 = 0, a, cnt = 0;
  while (n1) {
    a = n1 % 10;
    a1[c1] = a;
    c1++;
    n1 /= 10;
  }
  reverse(a1, a1 + 4);
  while (n2) {
    a = n2 % 10;
    a2[c2] = a;
    c2++;
    n2 /= 10;
  }
  reverse(a2, a2 + 4);
  for (int i = 0; i < 4; i++) {
    if (a1[i] != a2[i]) cnt++;
  }
  if (cnt > 1)
    return 0;
  else
    return 1;
}
int main() {
  int n, i, j, ara[2000], a, temp;
  string s = "";
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ara[i];
  }
  while (ara[0]) {
    a = ara[0] % 10;
    s += (a + '0');
    ara[0] /= 10;
  }
  reverse(s.begin(), s.end());
  if (s[0] == '1') {
    for (i = 1; i < n; i++) {
      if (s[i] != '0') {
        s[i] = '0';
        break;
      }
    }
  } else
    s[0] = '1';
  temp = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 +
         (s[3] - '0');
  ara[0] = temp;
  for (i = 1; i < n; i++) {
    int tt = ara[i];
    for (j = temp; j <= 2011; j++) {
      if (check(j, tt)) {
        ara[i] = j;
        break;
      }
    }
    temp = ara[i];
  }
  for (i = 0; i < n; i++) {
    if (ara[i] < 1000 || ara[i] > 2011) {
      printf("No solution\n");
      return 0;
    } else {
      if (ara[i] < ara[i - 1]) {
        printf("No solution\n");
        return 0;
      }
    }
  }
  for (i = 0; i < n; i++) {
    printf("%d\n", ara[i]);
  }
  return 0;
}
