#include <algorithm>
using namespace std;
struct Money
{
char name[20];
int aver = 0;
int discuss = 0;
char ganbu = 'N';
char WestStud = 'N';
int NumofPaper = 0;
int total = 0;
int ra = 0;
}mon[101];
bool cmp(Money a , Money b)
{
if(a.total != b.total) return (a.total > b.total);
else return (a.ra < b.ra);
}
//int price[5] = {8000 , 4000 , 2000 , 1000 , 850};
int main()
{
int n , s = 0 , i;
cin >> n;
for(i = 0; i < n; i++)
{
cin >> mon[i].name;
cin >> mon[i].aver >> mon[i].discuss;
cin >> mon[i].ganbu >> mon[i].WestStud;
cin >> mon[i].NumofPaper;
mon[i].ra = i;
}
for(i = 0; i < n; i++)
{
if(mon[i].aver > 80 && mon[i].NumofPaper >= 1) mon[i].total += 8000;
if(mon[i].aver > 85 && mon[i].discuss > 80) mon[i].total += 4000;
if(mon[i].aver > 90) mon[i].total += 2000;
if(mon[i].aver > 85 && mon[i].WestStud == 'Y') mon[i].total += 1000;
if(mon[i].discuss > 80 && mon[i].ganbu == 'Y') mon[i].total += 850;
s += mon[i].total;
}
sort(mon , mon + n , cmp);
cout << mon[0].name << endl;
cout << mon[0].total << endl;
cout << s << endl;
return 0;
}