#include <bits/stdc++.h>
bool good(int a, int b) {
  int cnt = 0;
  while (a) {
    if (a % 10 != b % 10) cnt++;
    a /= 10;
    b /= 10;
  }
  return cnt <= 1;
}
int main() {
  int n, a = 1000, b, i;
  int ans[1005], ansn = 0;
  scanf("%d", &n);
  for (int cnt = 0; cnt < n; ++cnt) {
    scanf("%d", &b);
    for (i = a; i < 2012; ++i)
      if (good(i, b)) {
        a = ans[ansn++] = i;
        break;
      }
  }
  if (ansn == n)
    for (i = 0; i < ansn; ++i) printf("%d\n", ans[i]);
  else
    puts("No solution");
  return 0;
}
