#include
#include
#include
#include
using namespace std ;
int main()
{
int i,j,n,m,pj,py,t,s,max,sum;
char gb,xb;
string name1,name;
scanf("%d",&m);
getchar();
for(i=0;i> name ;//此处不能用scanf("%s",&n);
scanf("%d %d %c %c %d",&pj,&py,&gb,&xb,&t);
if(pj>80&&t>=1)
s+=8000;
if(pj>85&&py>80)
s+=4000;
if(pj>90)
s+=2000;
if(pj>85&&xb=='Y')
s+=1000;
if(py>80&&gb=='Y')
s+=850;
if(s>max)
{
max=s;
name1=name;
}
sum+=s;
}
cout << name1 << endl ;//此处不能用printf("%s\n",name1);
printf("%d\n",max);
printf("%d\n",sum);
}
return 0;
}