#include <bits/stdc++.h>
using namespace std;
struct student{
int ID;
string name;
int age;
};
struct student num[1000];
bool guize(student x, student y ){
if( x.age > y.age) return true;
else return false;
}
int main(){
for(int i=0;i<8;i++){
cin >> num[i].ID >> num[i].name >> num[i].age;
}
sort( num+0, num+8, guize);
for(int i=0;i<8;i++){
cout << num[i].ID << " " << num[i].name << " " <<num[i].age <<endl;
}
return 0;
}