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