#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:100000000")
int deg[6];
int a[1050];
int toNumber(char* s) {
  int res = 0;
  for (int i = 0; i < 4; ++i) res += deg[i] * (s[i] - '0');
  return res;
}
char s[10];
int main() {
  int i, j, u;
  int n;
  deg[3] = 1;
  for (i = 2; i >= 0; --i) deg[i] = deg[i + 1] * 10;
  scanf("%d", &n);
  a[0] = 0;
  for (i = 1; i <= n; ++i) {
    scanf("%s", s);
    int mn = 9999;
    for (j = 0; j < 4; ++j) {
      int st = 0;
      if (j == 0) st++;
      char ch = s[j];
      for (u = st; u < 10; ++u) {
        s[j] = '0' + u;
        int xx = toNumber(s);
        if (xx >= a[i - 1]) mn = min(mn, toNumber(s));
      }
      s[j] = ch;
    }
    if (mn <= 2011)
      a[i] = mn;
    else {
      printf("No solution");
      return 0;
    }
  }
  for (i = 1; i <= n; ++i) printf("%d\n", a[i]);
  return 0;
}
