#include<iostream>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
struct student
{
char name[101];
int qmpj;
int bjpy;
char is_cadre;
char is_west;
int papers;
int sum_schoolership;
};
int main()
{
int number,i,j;
struct student stu[256];
cin>>number;
for(i=0;i<number;i++)
{
stu[i].sum_schoolership=0;
cin>>stu[i].name>>stu[i].qmpj>>stu[i].bjpy>>stu[i].is_cadre>>stu[i].is_west>>stu[i].papers;
}
for(i=0;i<number;i++)
{
if(stu[i].qmpj>80&&stu[i].papers>=1)
{
stu[i].sum_schoolership=stu[i].sum_schoolership+8000;
}
if(stu[i].qmpj>85&&stu[i].bjpy>80)
{
stu[i].sum_schoolership=stu[i].sum_schoolership+4000;
}
if(stu[i].qmpj>90)
{
stu[i].sum_schoolership=stu[i].sum_schoolership+2000;
}
if(stu[i].qmpj>85&&stu[i].is_west=='Y')
{
stu[i].sum_schoolership=stu[i].sum_schoolership+1000;
}
if(stu[i].bjpy>80&&stu[i].is_cadre=='Y')
{
stu[i].sum_schoolership=stu[i].sum_schoolership+850;
}
}
int totalmoney=0;
for(j=0;j<number;j++)
{
totalmoney=totalmoney+stu[j].sum_schoolership;
//cout<<stu[j].name<<" "<<stu[j].sum_schoolership<<endl;
}
int max=0,k;
for(j=0;j<number;j++)
{
if(stu[j].sum_schoolership>max)
{
max=stu[j].sum_schoolership;
k=j;
}
}
printf("%s
%d
%d
",stu[k].name,stu[k].sum_schoolership,totalmoney);
return 0;
}