#include<bits/stdc++.h>
using namespace std;
struct stu{
string name;
int eng,ma,chi,sum;
};
int s,max;
stu a[1001];
bool a1[1001];
int main(){
cin>>s;
for(int q=0;q<s;q++)
{
cin>>a[q].name>>[q]a.chi>>a[q].ma>>a[q].eng;
sum=a[q].chi+a[q].ma+a[q].eng;
}
for(int q=0;q<=s;q+=2)
{
if(a[q].sum<a[q+1].sum)
swap(a[q],a[q+1]);
}
max=a[1].sum;
int z=0;
while(sum==max)
{
cout<<a[z].name<<" "<<a[z].chi<<" "<<a[z].ma<<" "<<a[z].eng;
z++;
}
return 0;
}