#include <bits/stdc++.h>
using namespace std;
string s[500005];
int main() {
  int n;
  while (cin >> n) {
    char c;
    for (int i = 0; i < n; i++) cin >> c >> s[i];
    for (int i = n - 2; i >= 0; i--) {
      if (s[i] < s[i + 1])
        continue;
      else {
        int len1 = s[i].length();
        for (int j = 0; j < len1; j++) {
          if (s[i][j] > s[i + 1][j]) {
            s[i] = s[i].substr(0, j);
            break;
          }
        }
      }
    }
    for (int i = 0; i < n; i++) cout << "#" << s[i] << endl;
  }
  return 0;
}
