#include <bits/stdc++.h>
using namespace std;
char s[1000005], tmp[500005];
int n, len[500005], st[500005], res[500005], x;
void solve(int l, int r) {
  if (l > r) return;
  int small = l;
  for (int i = (l + 1); i <= (r); i++)
    if (s[st[i] + res[i]] < s[st[i - 1] + res[i - 1]]) {
      small = i;
    }
  while (small <= r && s[st[small] + res[small]] == 0) small++;
  for (int i = (small); i <= (r); i++) res[i]++;
  int pv = small;
  for (int i = (small + 1); i <= (r); i++)
    if (s[st[i] + res[i] - 1] != s[st[i - 1] + res[i - 1] - 1]) {
      solve(pv, i - 1);
      pv = i;
    }
  solve(pv, r);
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    scanf(" %s", tmp);
    len[i] = strlen(tmp) - 1;
    st[i] = x;
    for (int j = (1); j <= (len[i]); j++) s[x++] = tmp[j];
    s[x++] = 0;
  }
  solve(1, n);
  for (int i = (1); i <= (n); i++) {
    printf("#");
    for (int j = (0); j <= (res[i] - 1); j++) printf("%c", s[st[i] + j]);
    printf("\n");
  }
  return 0;
}
