#include <iostream>
#include <algorithm>
using namespace std;
const int N = 310;
int n;
struct student{
int name;
double chinese;
double score;
}stu[N];
bool cmp(student a, student b)
{
if (a.score != b.score) return a.score > b.score;
else
{
if (a.chinese != a.chinese) return a.chinese > b.chinese;
else return a.name < b.name;
}
}
int main()
{
double a, b, c;
cin >> n;
for (int i = 1; i <= n; i ++ )
{
cin >> a >> b >> c;
stu[i].name = i;
stu[i].chinese = a;
stu[i].score = a + b + c;
}
sort(stu + 1, stu + n + 1, cmp);
for (int i = 1; i <= 5; i ++ )
{
cout << stu[i].name << " " << stu[i].score << endl;
}
return 0;
}