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