#include<bits/stdc++.h>
#include<map>
using namespace std;
map<string,int> m;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
string s;
int x;
cin>>s>>x;
m[s]=x;
}
for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
cout<<it.first<<' '<<it.second<<'\n';
}
return 0;
}