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