#include <bits/stdc++.h>
using namespace std;
void XsliferX() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
long long f_p(long long x, int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return f_p((x * x), y / 2);
  else
    return (x * f_p((x * x), y / 2));
}
int dx[9] = {1, -1, 0, 0, 0, 1, -1, 1, -1};
int dy[9] = {0, 0, 1, -1, 0, 1, -1, -1, 1};
multiset<string> st, stt;
string arr[500005];
int n;
int main() {
  XsliferX();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    st.insert(arr[i]);
  }
  string s, ss;
  for (int i = 0; i < n; i++) {
    s = *st.begin();
    ss = "";
    for (int j = 0; j < min(arr[i].size(), s.size()); j++) {
      if (s[j] != arr[i][j]) break;
      ss += s[j];
    }
    st.erase(st.find(arr[i]));
    stt.insert(ss);
    arr[i] = ss;
  }
  for (int i = 0; i < n; i++) {
    s = *stt.begin();
    for (int j = 0; j < min(arr[i].size(), s.size()); j++) {
      if (s[j] != arr[i][j]) break;
      cout << s[j];
    }
    stt.erase(stt.find(arr[i]));
    cout << '\n';
  }
  return 0;
}
