#include
#include
#include
using namespace std;
int main()
{
// it is possible to have same keys
multimap<char,string> mp;
int n;
cin>>n;
for(int i=0;i<n;i++)
{
char ch;
string s;
cin>>ch>>s;
mp.insert(make_pair(ch,s));
}
// search
auto f=mp.find('c');
if(f->second=="cat"){
mp.erase(f);
}
for(auto it=mp.begin();it!=mp.end();it++)
{
cout<<mp->first<<" "<<mp->second<<endl;
}
}
// it is giving error