#include <bits/stdc++.h> using namespace std; typedef struct { int w; string hat; }Shu; bool cmp(Shu a,Shu b){ if(a.w > b.w) return true; else return false; } int main(){ int n; Shu tmp; vector<Shu> shu; cin>>n; while(n--){ cin>>tmp.w>>tmp.hat; shu.push_back(tmp); } sort(shu.begin(),shu.end(),cmp); for(int i = 0; i < shu.size(); i++) cout<<shu[i].hat<<endl; }