#include main(){int n,i;std::cin>>n;i=n;std::string a[n],t,u;while(i)std::cin>>t>>u,a[--i]=t+" "+u;sort(a,a+n);for(auto v:a)std::cout<