#include <iostream>
#include <vector>
#include <string>
using namespace std;
//字典树 典型题
struct nod{
nod* po[26];
int shu;
nod(){
shu=0;
for(int i=0;i<26;i++)
{
po[i]=NULL;
}
}
};
nod da[100000];
int js=1;
int main()
{
/*
for(int i=0;i<100000;i++)
{
da[i].shu=0;
for(int j=0;j<26;j++)
{
da[i].po[j]=NULL;
}
}*/
string s;
vector<string> ve;
while(cin>>s)
{
ve.push_back(s);
nod* tp=&da[0];
for(int i=0;i<s.size();i++)
{
if(tp->po[s[i]-'a']==NULL)
{
//cout<<"NULL "<<s[i]<<endl;
//cout<<"js "<<js<<endl;
tp->po[s[i]-'a']=&da[js];
js++;
}
tp=tp->po[s[i]-'a'];//tp=tp->po[s[i]-'0'] 痛苦
//cout<<"hi "<<da[js-1].shu<<endl;
//cout<<tp->shu<<endl;
(tp->shu)++;
//cout<<"hello"<<endl;
//cout<<s[i]<<" "<<tp->shu<<" "<<tp<<endl;
}
}
for(int i=0;i<ve.size();i++)
{
string s=ve[i];
//cout<<s<<endl;
nod* tp=&da[0];
int wz=s.size();
int flag=0;
for(int i=0;i<s.size();i++)
{
//(tp->shu)--;
tp=tp->po[s[i]-'a'];
//cout<<s[i]<<" "<<tp->shu<<endl;
if((tp->shu)==1)
{
if(flag==0)
{
flag=1;
wz=i;
}
}
}
//cout<<js<<endl;
cout<<s<<" "<<s.substr(0,wz+1)<<endl;
}
return 0;
}