#include <bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define forr(a,b,c) for(int a=b;a<c;a++)
#define forrev(a,b,c) for(int a=b;a>c;a--)
#define all(v) v.begin(),v.end()
#define revall(v) v.rbegin(),v.rend()
#define allk(v,k) v.begin()+k,v.end()
#define revallk(v,k) v.rbegin()+k,v.rend()
#define allkj(v,k,j) v.begin()+k,v.end()-j
#define revallkj(v,k,j) v.rbegin()+j,v.rend()-k
#define ff first
#define ss second
////////////////////////// non-modifiable /////////////////////////////////
#define mod 1000000007
#define eps 1e-9
#define inf INT_MAX
#define infl LONG_LONG_MAX
ll power(ll a,ll n)
{
if(a==0)return 0;
if(a==1 || n==0)return 1;
if(n==1)return a%mod;//can remove mod?
ll t=power(a,n/2);
t=t*t%mod;
if(n&1)return t*a%mod;
return t;
}
#define P (int)(2e6)+9
#define FACTORIZE 1
#define DETERMINE 2
/*int primes[P];
void sieve(int prime=2)//2->detects prime, 1->max prime in factorization
{
forr(i,2,P-3)
{
if(!primes[i])
for(int j=prime*i;j<P-3;j+=i)primes[j]=i;
}
//forr(i,1,21)cout<<primes[i]<<" ";cout<<endl;
if(prime==2)
{
forr(i,1,P-3)
{
primes[i] = ( primes[i] == 0 );
}
}
else
primes[1] = 1;
}*/
int popcount(ll a)
{
int c=0;
while(a)
{
c++;
a-=a&-a;
}
return c;
}
void factorize(int a)
{
}
void update(int tree[],int idx,int val,int maxval)
{
for(;idx<=maxval;idx+=idx&-idx)
{
tree[idx]+=val;
//tree[idx]%=mod;
}
}
int read(int tree[],int idx)
{
ll sum=0;
for(;idx>0;idx-=idx&-idx)
{
sum+=tree[idx];
//sum%=mod;
}
return sum;
}
////////////////////////// MODIFIABLE /////////////////////////////////////
struct node2
{
int id,val;
node2()
{
static int ctx=1;
id=ctx++;
};
node2(int a,int b=0,int c=0,int d=0,int e=0,int f=0)
{
val=a;
}
};
struct comp2
{
bool operator()(int a,int b)
{
//return a<b;
return b<a; //min heap
}
};
bool cmp2(int a,int b)
{
//return a<b;
return b<a;
}
struct node
{
bool present;
node * child[26];
node()
{
};
node(int a,int b=0,int c=0,int d=0,int e=0,int f=0)
{
//val=a;
}
};
struct comp
{
bool operator()(int a,int b)
{
//return a<b;
return b<a; //min heap
}
};
bool cmp(int a,int b)
{
//return a<b;
return b<a;
}
////////////////////////// custom-defined /////////////////////////////////
#define N 500009
int n,m,a,b,c,d,k,h,w,x,y,p,q,t,ans,res,ma,mi,T,act=0,pas=1,cur,flag,now;
int len[N];
string s[N];
node * root;
//vector<string> s;
double e,f,z;
vector<int> v[1], vec;
set<int> sett;
typedef map<int,int> Mapp;
Mapp mapp;
////////////////////////// variable declarations //////////////////////////
void print()//for detailed output of [a data structure]
{
}
void print2()//for detailed output of [a data structure]
{
}
void input()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n;
//scanf("%d",&n);
//cout << "n=" << n << endl;
forr(i,1,n+1) cin >> s[i];
//scanf("%s",s[i]);
//forr(i,1,n+1) cout << s[i] << endl;
//cout << " lol " << endl;
}
node * insert( node * root, string& s, int idx, int length, int sid )
{
if( root -> present == 1 )
{
len[ sid ] = idx;
return root;
}
if( idx == length )
{
root -> present = 1;
return root;
}
forr(i,0,s[idx]-'a')
if( root->child[i] != NULL )
{
len[ sid ] = idx;
root -> present = 1;
return root;
}
//if( root->child[ s[idx] - 'a' ] != NULL && )
if( root->child[ s[idx] - 'a' ] == NULL )
root->child[ s[idx] - 'a' ] = (node*) malloc( sizeof( node ) );
root->child[ s[idx] - 'a' ] = insert( root->child[ s[idx] - 'a' ], s, idx+1, length, sid );
return root;
}
void solve()
{
forr(i,1,n+1) len[i] = s[i].length();
root = (node*) malloc( sizeof( node ) );
forrev(i,n,0)
{
root = insert( root, s[i], 1, len[i], i );
}
}
void output()
{
char buffer[500009] = {0};
int id = 0;
forr(i,1,n+1)
{
forr(j,0,len[i])
buffer[id++] = s[i][j];
//printf("%c",s[i][j]);
buffer[id++] = '\n';
//printf("\n");
//cout << string( s[i].begin(), s[i].begin() + len[i] ) << endl;
}
//printf("%s\n",buffer);
buffer[ id-1 ] = 0;
cout << buffer;
}
///////////////////////////// my functions ////////////////////////////////
int main()
{
input();
solve();
output();
return 0;
}
//// MAIN //// MAIN //// MAIN //// MAIN //// MAIN //// MAIN //// MAIN ////
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcGIoYSkgcHVzaF9iYWNrKGEpCiNkZWZpbmUgbXAoYSxiKSBtYWtlX3BhaXIoYSxiKQojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHBpaSBwYWlyPGludCxpbnQ+CiNkZWZpbmUgcGxsIHBhaXI8bGwsbGw+CiNkZWZpbmUgZm9ycihhLGIsYykgZm9yKGludCBhPWI7YTxjO2ErKykKI2RlZmluZSBmb3JyZXYoYSxiLGMpIGZvcihpbnQgYT1iO2E+YzthLS0pCiNkZWZpbmUgYWxsKHYpIHYuYmVnaW4oKSx2LmVuZCgpCiNkZWZpbmUgcmV2YWxsKHYpIHYucmJlZ2luKCksdi5yZW5kKCkKI2RlZmluZSBhbGxrKHYsaykgdi5iZWdpbigpK2ssdi5lbmQoKQojZGVmaW5lIHJldmFsbGsodixrKSB2LnJiZWdpbigpK2ssdi5yZW5kKCkKI2RlZmluZSBhbGxraih2LGssaikgdi5iZWdpbigpK2ssdi5lbmQoKS1qCiNkZWZpbmUgcmV2YWxsa2oodixrLGopIHYucmJlZ2luKCkraix2LnJlbmQoKS1rCiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8gbm9uLW1vZGlmaWFibGUgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vCgojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgZ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