#include <bits/stdc++.h> using namespace std; class rat{ public: string hat; int weight; }; bool cmp(rat r1, rat r2){ return r1.weight>r2.weight; } int main() { int n;cin>>n; vector<rat>v; while(n--){ int temp;string s; cin>>temp>>s; rat r; r.hat = s; r.weight = temp; v.push_back(r); } sort(v.begin(),v.end(),cmp); for(auto r:v) cout<<r.hat<<endl; } // 64 位输出请用 printf("%lld")