#include <bits/stdc++.h>
using namespace std;
char str[1005][5];
int n, ans[1005];
int getnum(char str[]) {
  return (str[0] - '0') * 1000 + (str[1] - '0') * 100 + (str[2] - '0') * 10 +
         (str[3] - '0');
}
void find(int ori, int d) {
  int key;
  if (d == 0) {
    if (str[d][0] > '1')
      str[d][0] = '1';
    else {
      for (int i = 1; i < 4; i++)
        if (str[d][i] > '0') {
          str[d][i] = '0';
          break;
        }
    }
    key = getnum(str[d]);
    ans[d] = key;
    find(key, d + 1);
  } else if (d == n) {
    if (ori > 2011)
      printf("No solution\n");
    else {
      for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
    }
  } else {
    ans[d] = 9999;
    char tmp[5];
    strcpy(tmp, str[d]);
    tmp[0] = '1';
    key = getnum(tmp);
    if (key >= ori) ans[d] = key;
    tmp[0] = '2';
    key = getnum(tmp);
    if (key >= ori) ans[d] = min(key, ans[d]);
    for (int i = 1; i < 4; i++) {
      strcpy(tmp, str[d]);
      for (int j = 0; j < 10; j++) {
        tmp[i] = j + '0';
        key = getnum(tmp);
        if (key >= ori) ans[d] = min(key, ans[d]);
      }
    }
    if (ans[d] > 2011)
      printf("No solution\n");
    else
      find(ans[d], d + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", &str[i]);
  find(0, 0);
}
