#include <iostream>
#include <string>
using namespace std;
//英语 抄博友程序
int main()
{
int T;
cin>>T;
string jmz;
int jac=-1;
int jff=-1;
for(int o=0;o<T;o++)
{
string mz;
int a[4];
int b[4];
cin>>mz;
int ac=0;
int ff=0;
for(int i=0;i<4;i++)
{
cin>>a[i]>>b[i];
if(b[i]!=0)
{
ac++;
ff=ff+(a[i]-1)*20+b[i];
}
}
if(ac>jac)
{
jac=ac;
jmz=mz;
jff=ff;
}else if(ac==jac)
{
if(jff>ff)
{
jac=ac;
jmz=mz;
jff=ff;
}
}
}
cout<<jmz<<" "<<jac<<" "<<jff<<endl;
}