#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
int n;
char c;
string str[N];
int solve(int x, int i) {
  string s(str[i - 1], 0, x);
  if (s > str[i])
    return 1;
  else
    return 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    cin >> str[i];
  }
  for (int i = n - 1; i >= 1; i--) {
    int l = 0, r = max(str[i].length(), str[i - 1].length());
    int mid;
    while (l <= r) {
      mid = (l + r) / 2;
      if (solve(mid, i))
        r = mid - 1;
      else
        l = mid + 1;
    }
    str[i - 1] = string(str[i - 1], 0, r);
  }
  for (int i = 0; i < n; i++) {
    cout << "#" << str[i] << endl;
  }
  return 0;
}
