#include <iostream>
using namespace std;
int n,money[101];
long long sum,Max,maxm;
struct node {
char name[21];
int qimo;
int banji;
char ganbu;
char xibu;
int lunwen;
int money;
}people[101];
bool yuanshi(node a)
{
if (a.qimo > 80 && a.lunwen == 1)
return true;
else return false;
}
bool wushi(node a)
{
if (a.qimo > 85 && a.banji > 80)
return true;
else return false;
}
bool chengji(node a)
{
if (a.qimo > 90)
return true;
else return false;
}
bool xibu(node a)
{
if (a.xibu == 'Y' && a.qimo > 85)
return true;
else return false;
}
bool banjijiang(node a)
{
if (a.banji > 80&&a.ganbu=='Y')
return true;
else return false;
}
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> people[i].name >> people[i].qimo >> people[i].banji >> people[i].ganbu >> people[i].xibu >> people[i].lunwen;
if (yuanshi(people[i]))
people[i].money += 8000;
if (wushi(people[i]))
people[i].money += 4000;
if (chengji(people[i]))
people[i].money += 2000;
if (xibu(people[i]))
people[i].money += 1000;
if (banjijiang(people[i]))
people[i].money += 850;
sum += people[i].money;
if (people[i].money > maxm)
{
maxm = people[i].money;
Max = i;
}
}
cout << people[Max].name << endl << people[Max].money << endl << sum;
return 0;
}