#include <bits/stdc++.h>
using namespace std;
typedef pair<int, string> PIS;
bool my_cmp(PIS m1, PIS m2){
return m1.first > m2.first;
}
int main(){
int n;
while(cin >> n){
vector<PIS> mouse;
for (int i=0; i<n; i++){
int w;
string color;
cin >> w >> color;
mouse.push_back({w, color});
}
sort(mouse.begin(), mouse.end(), my_cmp);
for (auto item : mouse){
cout << item.second << endl;
}
}
return 0;
}



京公网安备 11010502036488号