#include <bits/stdc++.h>
using namespace std;
int sol(int a, int b) {
  int ca[5];
  int cb[5];
  int aa = a;
  int bb = b;
  for (int i = 4; i >= 1; i--) {
    ca[i] = aa % 10;
    aa /= 10;
    cb[i] = bb % 10;
    bb /= 10;
  }
  aa = a;
  bb = b;
  int cca[5];
  memcpy(cca, ca, sizeof(cca));
  if (aa == bb) {
    if (bb > 2011) return -1;
    return aa;
  }
  if (a > b) {
    aa = a;
    memcpy(ca, cca, sizeof(ca));
    if (ca[1] > 1 && aa - bb >= 1000) {
      while (ca[1] > 1 && aa - 1000 >= bb) {
        aa -= 1000;
        ca[1]--;
      }
      if (aa <= 2011) return aa;
      if (aa > 2011) return -1;
    } else if (ca[2] > 0 && aa - bb >= 100) {
      while (ca[2] > 0 && aa - 100 >= bb) {
        aa -= 100;
        ca[2]--;
      }
      if (aa <= 2011) return aa;
    } else if (ca[3] > 0 && aa - bb >= 10) {
      while (ca[3] > 0 && aa - 10 >= bb) {
        aa -= 10;
        ca[3]--;
      }
      if (aa <= 2011) return aa;
    } else if (ca[4] > 0 && aa - bb >= 1) {
      while (ca[4] > 0 && aa - 1 >= bb) {
        aa--;
        ca[4]--;
      }
      if (aa <= 2011) return aa;
    }
    if (aa <= 2011) return aa;
    return -1;
  } else if (a < b) {
    aa = a;
    while (ca[4] < 9) {
      ca[4]++;
      aa++;
      if (aa >= bb && aa <= 2011) return aa;
      if (aa > 2011) return -1;
    }
    memcpy(ca, cca, sizeof(ca));
    aa = a;
    while (ca[3] < 9) {
      ca[3]++;
      aa += 10;
      if (aa >= bb && aa <= 2011) return aa;
      if (aa > 2011) return -1;
    }
    memcpy(ca, cca, sizeof(ca));
    aa = a;
    while (ca[2] < 9) {
      ca[2]++;
      aa += 100;
      if (aa >= bb && aa <= 2011) return aa;
      if (aa > 2011) return -1;
    }
    memcpy(ca, cca, sizeof(ca));
    aa = a;
    while (ca[1] < 2) {
      ca[1]++;
      aa += 1000;
      if (aa >= bb && aa <= 2011) return aa;
      if (aa > 2011) return -1;
    }
  }
  return -1;
}
int main() {
  int n;
  int a[1010];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int ans[1010];
  ans[1] = sol(a[1], 1000);
  if (ans[1] == -1) {
    cout << "No solution" << endl;
    return 0;
  }
  int flag = 1;
  for (int i = 2; i <= n; i++) {
    ans[i] = sol(a[i], ans[i - 1]);
    if (ans[i] == -1) {
      cout << "No solution" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
