#include "iostream" #include "string" #include "map" using namespace std; int main() { int num, iHeavy; while (cin >> num) { map<int, string> result; for (int i = 0; i < num; ++i) cin >> iHeavy >> result[iHeavy]; // input for (auto itor = result.rbegin(); itor != result.rend(); itor++) cout << itor->second << endl; // output } }