#include using namespace std;
typedef struct stu { string name; int age; int score; }stu, * s;
s scoresort(s sheet, int num) { for (int i = 0; i < num; i++) { int flag = 0; for (int j = num - 1; j > i; j--) { if (sheet[j].score < sheet[j - 1].score) { swap(sheet[j], sheet[j - 1]); flag = 1; } else if (sheet[j].score == sheet[j - 1].score && sheet[j].name < sheet[j - 1].name) { swap(sheet[j], sheet[j - 1]); flag = 1; } else if (sheet[j].score == sheet[j - 1].score && sheet[j].name == sheet[j - 1].name && sheet[j].age < sheet[j - 1].age) { swap(sheet[j], sheet[j - 1]); flag = 1; } } if (!flag) break; } return sheet; }
int main() { int num; cin >> num; s sheet = new stu[num]; for (int i = 0; i < num; i++) { cin >> sheet[i].name >> sheet[i].age >> sheet[i].score; } scoresort(sheet, num); for (int i = 0; i < num; i++) cout << sheet[i].name << " " << sheet[i].age << " " << sheet[i].score << endl; }