#include<iostream>
#include<cstring>
using namespace std;
char b,c;
string n,max2;
int a,q,z,s;
int main()
{
int m,max1=0,t=0;
cin>>m;
for(int i=1;i<=m;i++)
{
s=0;
cin>>n>>q>>z>>b>>c>>a;
if(q>80&&a>=1)s+=8000;
if(q>85&&z>80)s+=4000;
if(q>90)s+=2000;
if(q>85&&c=='Y')s+=1000;
if(q>80&&b=='Y')s+=850;
t+=s;
if(s>max1)
{max1=s;max2=n;}
}
cout<<max2<<endl;
cout<<max1<<endl;
cout<<t;
return 0;
}```