//土尔逊Torson 编写于2023/4/12
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
using namespace std;
struct rat { //定义老鼠,define RAT
int weight;
char hat[10];
};
bool comp029(rat left, rat right) {
if (left.weight > right.weight)
{
return true;
}
else {
return false;
}
}
int main() {
int n;
rat Labrat[100];
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; ++i) {
scanf("%d %s", &Labrat[i].weight, &Labrat[i].hat);
}
sort(Labrat, Labrat + n, comp029);
for (int j = 0; j < n; ++j) {
printf("%s\n", Labrat[j].hat);
}
}
system("pause");
return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")