#include <bits/stdc++.h>
using namespace std;
int n;
string cur, pre;
vector<string> ans;
void init() { cin >> n; }
void solve() {
  pre = "1000";
  for (int i = 0; i < n; i++) {
    cin >> cur;
    if (cur == pre) {
      ans.push_back(cur);
      pre = cur;
      continue;
    }
    if (cur[0] > '2') {
      cur[0] = '1';
      if (cur >= pre) {
        ans.push_back(cur);
      } else {
        cur[0] = '2';
        if (cur >= pre && cur <= "2011") {
          ans.push_back(cur);
        } else {
          cout << "No solution" << endl;
          return;
        }
      }
      pre = cur;
      continue;
    }
    if (pre[0] == '1' && cur[0] == '2') {
      cur[0] = '1';
      if (cur >= pre) {
        ans.push_back(cur);
      } else {
        cur[0] = '2';
        if (cur[1] > '0') {
          cur[1] = '0';
          if (cur <= "2011") {
            ans.push_back(cur);
          } else {
            cout << "No solution" << endl;
            return;
          }
        } else if (cur[2] > '0') {
          cur[2] = '0';
          ans.push_back(cur);
        } else {
          cur[3] = '0';
          ans.push_back(cur);
        }
      }
      pre = cur;
      continue;
    }
    if (pre[0] == '2' && cur[0] == '1') {
      cur[0] = '2';
      if (cur >= pre && cur <= "2011") {
        ans.push_back(cur);
      } else {
        cout << "No solution" << endl;
        return;
      }
      pre = cur;
      continue;
    }
    if (pre[0] == '2' && cur[0] == '2') {
      if (cur[1] > '0') {
        cur[1] = '0';
        if (cur >= pre && cur <= "2011") {
          ans.push_back(cur);
        } else {
          cout << "No solution" << endl;
        }
      } else {
        if (pre[2] == '1') {
          if (cur[2] == '1') {
            cur[3] = pre[3];
            ans.push_back(cur);
          } else {
            cur[2] = '1';
            if (cur >= pre && cur <= "2011") {
              ans.push_back(cur);
            } else {
              cout << "No solution" << endl;
            }
          }
        } else {
          if (cur[2] == '0') {
            cur[3] = pre[3];
            ans.push_back(cur);
          } else if (cur[2] > '1') {
            cur[2] = '0';
            if (cur >= pre) {
              ans.push_back(cur);
            } else {
              cur[2] = '1';
              if (cur >= pre && cur <= "2011") {
                ans.push_back(cur);
              } else {
                cout << "No solution" << endl;
              }
            }
          } else {
            if (pre[3] > cur[3]) {
              cur[3] = '0';
              ans.push_back(cur);
            } else {
              cur[2] = '0';
              ans.push_back(cur);
            }
          }
        }
      }
      pre = cur;
      continue;
    }
    for (int j = 1; j < 4; j++) {
      if (cur[j] != pre[j]) {
        char tmp = cur[j];
        cur[j] = pre[j];
        if (cur >= pre && cur <= "2011") {
          ans.push_back(cur);
          pre = cur;
          break;
        }
        cur[j] = tmp;
        if (pre[j] < '9') {
          if (cur[j] != pre[j] + 1) {
            cur[j] = pre[j] + 1;
            ans.push_back(cur);
            pre = cur;
            break;
          }
          for (int k = j + 1; k < 4; k++) {
            if (cur[k] != '0') {
              cur[k] = '0';
              break;
            }
          }
          ans.push_back(cur);
          pre = cur;
          break;
        }
        if (j == 1) {
          cur[0] = '2';
          if (cur >= pre && cur <= "2011") {
            ans.push_back(cur);
          } else {
            cout << "No solution" << endl;
            return;
          }
        } else if (j == 2) {
          if (pre[1] == '9') {
            cout << "No solution" << endl;
            return;
          } else {
            cur[1] = pre[1] + 1;
            ans.push_back(cur);
          }
        }
        pre = cur;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}
int main() {
  init();
  solve();
  return 0;
}
