#include <bits/stdc++.h>
using namespace std;
bool possible = 1;
void change(char str[], char mask[]) {
  char best[6];
  best[0] = '\0';
  for (int i = 0; i < (4); ++i) {
    for (int d = 0; d < (10); ++d)
      if (!(i == 0 && d == 0)) {
        char temp = str[i];
        str[i] = (d + '0');
        if (strcmp(str, mask) >= 0) {
          if (best[0] == '\0')
            strcpy(best, str);
          else if (strcmp(best, str) > 0)
            strcpy(best, str);
        }
        str[i] = temp;
      }
  }
  if (strcmp(best, "2011") > 0) possible = 0;
  strcpy(str, best);
}
int main() {
  int n;
  scanf("%d", &n);
  char in[1005][6];
  for (int i = 0; i < (n); ++i) scanf("%s", in[i]);
  change(in[0], "1000");
  possible = 1;
  for (int i = (1); i <= (n - 1); ++i) {
    change(in[i], in[i - 1]);
  }
  if (!possible)
    puts("No solution");
  else {
    for (int i = 0; i < (n); ++i) printf("%s\n", in[i]);
  }
  return 0;
}
