#include <bits/stdc++.h> #define MAX 30 using namespace std; typedef struct worker { int num; string name; int age; } worker; bool cmp(worker a, worker b) { if (a.age < b.age) return true; else if (a.age == b.age && a.num < b.num) return true; else if (a.age == b.age && a.num == b.num && a.name < b.name) return true; else return false; } int main() { int n; cin >> n; worker data[MAX]; for (int i = 0; i < n; i++) cin >> data[i].num >> data[i].name >> data[i].age; sort(data, data + n, cmp); for (int i = 0; i < 3; i++) cout << data[i].num << " " << data[i].name << " " << data[i].age << endl; }