#include <bits/stdc++.h>
int a[1010];
int s1[4], s2[4];
void change(int x, int s[]) {
  int i;
  for (i = 3; x; i--) {
    s[i] = x % 10;
    x = x / 10;
  }
}
int getmin(int k) {
  int i, j, num;
  change(a[k], s1);
  for (i = a[k - 1]; i < 2012; i++) {
    change(i, s2);
    num = 0;
    for (j = 0; j < 4; j++)
      if (s1[j] != s2[j]) num++;
    if (num <= 1) return i;
  }
  return -1;
}
bool solve(int n) {
  int i, k;
  for (i = 1; i <= n; i++) {
    k = getmin(i);
    if (k > -1)
      a[i] = k;
    else if (k == -1)
      return false;
  }
}
int main() {
  int n;
  int i;
  while (scanf("%d", &n) != EOF) {
    a[0] = 1000;
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    if (solve(n) == false)
      printf("No solution\n");
    else {
      for (i = 1; i <= n; i++) printf("%d\n", a[i]);
    }
  }
  return 0;
}
