#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
const int INF = INT_MAX / 2;
const long double EPS = 1e-9;
const long double PI = 3.1415926535897932384626433832795;
const int N = 1000 + 13;
const int second = 3000 + 13;
string s[N];
int p[N][second];
bool z[N][second];
string str[second];
inline int toInt(string s) {
  int cur = 0;
  int st = 1;
  for (int i = int(4) - 1; i >= 0; i--) cur += (int)(s[i] - '0') * st, st *= 10;
  return cur;
}
inline string toStr(int x) {
  if (str[x] != "") return str[x];
  stringstream ss;
  ss << x;
  string ans;
  ss >> ans;
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> s[i];
  memset(p, -1, sizeof(p));
  for (int i = 0; i < int(second); i++) str[i] = "";
  for (int i = 0; i < int(4); i++)
    for (int j = 0; j < int(10); j++) {
      string cur = s[0];
      if (i > 0 || (i == 0 && j > 0)) cur[i] = char('0' + j);
      int val = toInt(cur);
      if (val < 1000 || val > 2011) continue;
      z[1][val] = true;
      p[1][val] = 1;
    }
  for (int i = int(1); i <= int(n - 1); i++)
    for (int j = int(1000); j <= int(second - 1); j++) {
      if (!z[i][j]) continue;
      for (int i1 = 0; i1 < int(4); i1++)
        for (int j1 = 0; j1 < int(10); j1++) {
          string cur = s[i];
          if (i1 > 0 || (i1 == 0 && j1 > 0)) cur[i1] = char('0' + j1);
          int val = toInt(cur);
          if (val < 1000 || val > 2011) continue;
          if (val < j) continue;
          z[i + 1][val] = true;
          p[i + 1][val] = j;
        }
    }
  int ans = -1;
  for (int i = 0; i < int(second); i++)
    if (z[n][i]) {
      ans = i;
      break;
    }
  vector<int> res;
  if (ans == -1) {
    puts("No solution");
    return 0;
  }
  for (int i = n, j = ans; i >= 1;) {
    int nexti = i - 1;
    int nextj = p[i][j];
    res.push_back(j);
    i = nexti;
    j = nextj;
  }
  for (int i = int(int((res).size())) - 1; i >= 0; i--) printf("%d\n", res[i]);
  return 0;
}
