#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
using namespace std;
struct stu
{
string name;int scho;int total;
};
int main()
{
int n;
stu ans;
cin>>n;
string name;int term,judge,p;
char of,west;
ans.total=0;
ans.scho=0;
for(int i=1;i<=n;i++)
{
int temp(0);
cin>>name>>term>>judge>>of>>west>>p;
if(term>80&&p>=1)
temp+=8000;
if(term>85&&judge>80)
temp+=4000;
if(term>90)
temp+=2000;
if(west=='Y'&&term>85)
temp+=1000;
if(of=='Y'&&judge>80)
temp+=850;
ans.total+=temp;
if(ans.scho<temp)
{
ans.name=name;
ans.scho=temp;
}
}
printf("%s\n%d\n%d\n",(ans.name).c_str(),ans.scho,ans.total);
return 0;
}
/**************************************************************
Problem: 2256
User: admin
Language: C++
Result: Accepted
Time:69 ms
Memory:2076 kb
****************************************************************/