#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
long long sum=0;
int n;
struct stu{
string name;
char stug,west;
int c1,c2,l,money;
}a[1000005];
bool cmp(stu x,stu y){
if(x.money<y.money){
return 0;
}else{
return 1;
}
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].c1>>a[i].c2>>a[i].stug>>a[i].west>>a[i].l;
if(a[i].c1>80&&a[i].l>0) a[i].money+=8000;
if(a[i].c1>85&&a[i].c2>80) a[i].money+=4000;
if(a[i].c1>90) a[i].money+=2000;
if(a[i].c1>85&&a[i].west=='Y') a[i].money+=1000;
if(a[i].c2>80&&a[i].stug=='Y') a[i].money+=850;
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++){
sum+=a[i].money;
}
cout<<a[0].name<<"\n"<<a[0].money<<"\n"<<sum;
return 0;
}