#include<iostream>
#include<map>
using namespace std;
int main() {
multimap<int, string>mouse;
int N;
cin >> N;
while (N--) {
int weight;
string color;
cin >> weight>> color;
mouse.insert(make_pair(weight, color));
}
for (multimap<int, string>::reverse_iterator it = mouse.rbegin(); it != mouse.rend(); ++it) {
cout << it->second << endl;
}
}

京公网安备 11010502036488号