#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int to_year(int a, int b, int c, int d) {
  return a * 1000 + 100 * b + 10 * c + d;
}
int min_year(int year, int minv) {
  int d = year % 10;
  int c = (year / 10) % 10;
  int b = (year / 100) % 10;
  int a = (year / 1000) % 10;
  int mmin = 10000;
  for (int i = 1; i <= 2; i++) {
    int y = to_year(i, b, c, d);
    if (y >= minv && y <= 2011) {
      mmin = min(y, mmin);
      break;
    }
  }
  for (int i = 0; i <= 9; i++) {
    int y = to_year(a, i, c, d);
    if (y >= minv && y <= 2011) {
      mmin = min(y, mmin);
      break;
    }
  }
  for (int i = 0; i <= 9; i++) {
    int y = to_year(a, b, i, d);
    if (y >= minv && y <= 2011) {
      mmin = min(y, mmin);
      break;
    }
  }
  for (int i = 0; i <= 9; i++) {
    int y = to_year(a, b, c, i);
    if (y >= minv && y <= 2011) {
      mmin = min(y, mmin);
      break;
    }
  }
  return mmin;
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int min = 1000;
  vector<int> v;
  for (int i = (0); i < (N); ++i) {
    int year;
    cin >> year;
    min = min_year(year, min);
    if (min == 10000) {
      cout << "No solution" << endl;
      return 0;
    }
    v.push_back(min);
  }
  for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i) {
    cout << *i << endl;
  }
  return 0;
}
