#include <cstdlib>
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
struct info{
string name;
int examScore;
int classScore;
char ganbu;
char xibu;
int lecture;
};
struct result{
string name;
int count;
int sum;
};
void input(info info[], int N)
{
for(int i = 0; i < N; ++i)
std::cin>>info[i].name>>info[i].examScore>>info[i].classScore>>info[i].ganbu>>info[i].xibu>>info[i].lecture;
}
void output(result re)
{
std::cout<<re.name<<endl;
std::cout<<re.count<<endl;
std::cout<<re.sum<<endl;
}
void cul(info std[],int N)
{
int oldCount = 0,newCount = 0,sum = 0;
int pos = -1;
for(int i = 0; i < N; ++i)
{
newCount = 0;
if(std[i].examScore > 90)
{
newCount +=2000;
sum += 2000;
}
if(std[i].examScore > 80 && std[i].lecture > 0)
{
newCount +=8000;
sum +=8000;
}
if(std[i].examScore > 85 && std[i].classScore > 80)
{
newCount +=4000;
sum +=4000;
}
if(std[i].examScore > 85 && std[i].xibu == 'Y')
{
newCount +=1000;
sum +=1000;
}
if(std[i].classScore > 80 && std[i].ganbu == 'Y')
{
newCount +=850;
sum +=850;
}
if(oldCount < newCount)
{
oldCount = newCount;
pos = i;
}
}
result re;
re.name = std[pos].name;
re.count = oldCount;
re.sum = sum;
output(re);
}
int main(int argc, char** argv)
{
int N;
std::cin>>N;
if(N < 1 || N > 100)
return -1;
info std[N];
input(std,N);
cul(std,N);
return 0;
}