#include <bits/stdc++.h>
int main() {
  char y[1005][5], temp[5];
  int n, i, j, k, flag;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", y[i]);
    flag = 0;
    if (strcmp(y[n - 1], "2011") < 0)
      for (i = 0; i < 4; i++) {
        strcpy(temp, y[n - 1]);
        for (j = 9; j >= 0; j--) {
          temp[i] = j + '0';
          if (strcmp(temp, "2011") <= 0 && strcmp(temp, y[n - 1]) > 0) {
            strcpy(y[n - 1], temp);
            flag = 1;
            break;
          }
        }
        if (flag) break;
      }
    else if (strcmp(y[n - 1], "2011") > 0)
      for (i = 3; i >= 0; i--) {
        strcpy(temp, y[n - 1]);
        for (j = 9; j >= 0; j--) {
          temp[i] = j + '0';
          if (strcmp(temp, "2011") <= 0) {
            strcpy(y[n - 1], temp);
            flag = 1;
            break;
          }
        }
        if (flag) break;
      }
    for (i = n - 2; i >= 0; i--) {
      flag = 0;
      if (strcmp(y[i], y[i + 1]) < 0)
        for (j = 0; j < 4; j++) {
          strcpy(temp, y[i]);
          for (k = 9; k >= 0; k--) {
            temp[j] = k + '0';
            if (temp[0] != '0' && strcmp(temp, y[i + 1]) <= 0 &&
                strcmp(temp, y[i]) > 0) {
              strcpy(y[i], temp);
              flag = 1;
              break;
            }
          }
          if (flag) break;
        }
      else if (strcmp(y[i], y[i + 1]) > 0)
        for (j = 3; j >= 0; j--) {
          strcpy(temp, y[i]);
          for (k = 9; k >= 0; k--) {
            temp[j] = k + '0';
            if (temp[0] != '0' && strcmp(temp, y[i + 1]) <= 0) {
              strcpy(y[i], temp);
              flag = 1;
              break;
            }
          }
          if (flag) break;
        }
      if (strcmp(y[i], y[i + 1]) > 0) {
        printf("No solution\n");
        return 0;
      }
    }
    for (i = 0; i < n; i++) printf("%s\n", y[i]);
  }
  return 0;
}
