#include <bits/stdc++.h>
using namespace std;
void finddate(const char *minv, char *v) {
  char tmp[5];
  char ans[] = "2012";
  for (int i = 0; i < 4; i++) {
    strcpy(tmp, v);
    for (char j = (i ? '0' : '1'); j <= '9'; j++) {
      tmp[i] = j;
      if (strcmp(tmp, minv) >= 0 && strcmp(tmp, ans) < 0) strcpy(ans, tmp);
    }
  }
  strcpy(v, ans);
}
int main(void) {
  int n;
  scanf("%d", &n);
  char first[] = "1000";
  char s[1000][5];
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    finddate((i ? s[i - 1] : first), s[i]);
    if (strcmp(s[i], "2011") > 0) {
      printf("No solution");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) printf("%s\n", s[i]);
}
