#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const double PI = 3.141592653589793238462643383279502884;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    cin >> v[i];
  }
  for (int i = n - 1; i >= 1; i--) {
    string noew;
    string buf = "";
    int ok = 0;
    string equal_part;
    int x = 0;
    while (x < min(v[i].size(), v[i - 1].size()) && v[i][x] == v[i - 1][x]) {
      equal_part.push_back(v[i][x]);
      x++;
    }
    for (int j = 0; j < min(v[i].size(), v[i - 1].size()); j++) {
      if (v[i][j] > v[i - 1][j]) {
        ok = 1;
        break;
      } else if (v[i][j] < v[i - 1][j]) {
        ok = 2;
        break;
      }
    }
    if (ok == 0) {
      noew = equal_part;
    }
    if (ok == 1) {
      noew = v[i - 1];
    } else if (ok == 2) {
      noew = equal_part;
    }
    v[i - 1] = noew;
  }
  for (auto i : v) {
    cout << "#" << i << '\n';
  }
}
