#include"bits/stdc++.h" using namespace std;struct x{string f,s;};int n,i;main(){cin>>n;x A[n];for(i=0;n>i;)cin>>A[i].f>>A[i++].s;sort(A,A+n,[&](x a,x b){return(a.f==b.f?a.si;)cout<