#include <bits/stdc++.h>
int a[1009];
int main() {
  int n, i, j, mark, k;
  int x;
  int c[4], b[4];
  while (scanf("%d", &n) != EOF) {
    a[0] = 1000;
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    mark = 0;
    for (i = 1; i <= n; i++) {
      x = a[i];
      for (j = 0; j < 4; j++) {
        b[j] = x % 10;
        x /= 10;
      }
      for (j = a[i - 1]; j <= 2011; j++) {
        x = j;
        int sum = 0;
        for (k = 0; k < 4; k++) {
          c[k] = x % 10;
          if (c[k] != b[k]) sum++;
          x /= 10;
        }
        if (sum <= 1) {
          a[i] = j;
          break;
        }
      }
      if (j > 2011) {
        mark = 1;
        break;
      }
    }
    if (mark)
      printf("No solution\n");
    else {
      for (i = 1; i <= n; i++) printf("%d\n", a[i]);
    }
  }
}
