#include <iostream> #include <algorithm> #include <string> using namespace std; const int MAXN = 100; struct mouse { int weight; string color; }; bool Compare (mouse x, mouse y){ return x.weight > y.weight; } int main () { int n; cin >> n; mouse mos[MAXN]; for (int i = 0; i < n; i++){ cin >> mos[i].weight >> mos[i].color; } sort (mos, mos + n, Compare); for (int i = 0; i < n; i++){ cout << mos[i].color << endl; } return 0; }