#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<string>Allstring[27];
int r = 0;
void Find(int i ,int j){
string s1;
int halflen1,halflen2;
bool x = false;
for(int k = 1 ; k<Allstring[i].size() ; k++ ){
x = false;
if( !Allstring[i][j].find(Allstring[i][k]) ){
halflen1 = Allstring[i][k].size();
halflen2 = Allstring[i][j].size() - halflen1;
s1=Allstring[i][j].substr(halflen1,halflen2);
if(s1.length()>0){
x = true;
}
}
if(x==true){
for(int i2 = 0 ; i2<=r ; i2++){
if(Allstring[i2][0][0] == s1[0]){
for(int j2 = 1 ; j2<Allstring[i2].size() ; j2++){
if(s1==Allstring[i2][j2]){
cout<<Allstring[i][j]<<"\n";
return;
}
}
}
}
}
}
}
int main()
{
//freopen("in.txt","r",stdin);
string word;
for(int i = 0 ; i<27 ; i++){
Allstring[i].resize(1);
}
while(cin>>word){
if(word[0]==Allstring[r][0][0]){
Allstring[r].push_back(word);
}else{
r++;
Allstring[r][0] = word[0];
Allstring[r].push_back(word);
}
}
/*for(int i = 0 ; i<=r ; i++){
for(int j = 1 ; j<Allstring[i].size() ; j++){
cout<<Allstring[i][j]<<" ";
}
cout<<"\n";
}*/
for(int i = 0 ; i<=r ; i++){
for(int j = 1 ; j<Allstring[i].size() ; j++){
Find(i,j);
}
}
}
/*
注意:
1. 当vector容器中因为没有添加值而无法比较时,记得可以用resize()
2. 不要因为自己不太明白某个语法就心生胆怯,有时候觉得很难,实际上用
过之后会发现其实很简单
3. 在比赛过程中,如果发现测试很难,并且代码循环较多无法找到问题时,
先放着,做其他题目,做完之后回头时可以尝试重新写一遍。
*/