#include<iostream>
#include<string>
using namespace std;
int n,mx=0,all=0,mxnm;
int main(){
scanf("%d",&n);
string nm[n+1];
int cj[n+1],py[n+1],lw[n+1],mn[n+1]={0};//这一行,mn函数的初始化及其不可忽视,不然会WA。我在此处错了3次
char gb[n+1],ws[n+1];
for(int i=1;i<=n;i++){
cin>>nm[i]>>cj[i]>>py[i]>>gb[i]>>ws[i]>>lw[i];
}
for(int i=1;i<=n;i++){
if(cj[i]>80&&lw[i]>=1) mn[i]+=8000;
if(cj[i]>85&&py[i]>80) mn[i]+=4000;
if(cj[i]>90) mn[i]+=2000;
if(cj[i]>85&&ws[i]=='Y') mn[i]+=1000;
if(py[i]>80&&gb[i]=='Y') mn[i]+=850;
all+=mn[i];
if(mn[i]>mx){
mx=mn[i];
mxnm=i;
}
}
cout<<nm[mxnm]<<endl<<mx<<endl<<all;
return 0;
}