

/*???????????????????????????????????????????? 

1) ????????8000??????????80??>80??
?????????1??1????????????? 
2) ????????4000??????????85??>85??
??????????80??>80????????? 
3) ????????2000??????????90??>90?
???????? 
4) ????????1000??????????85??>85?
???????????? 
5) ????????850??????????80??>80?
?????????? 

????????????????????????????????????????????????????????87????????82????????????????????????????????????????4850?? 

??????????????????????????????????????????????????
???? 
?????????????????????????????????????????????????????????????????????????????????????????N?????????????
 
???? 
4
YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1

 
???? 
ChenRuiyi
9000
28700
 

 
*/
struct student{
		char name[30];
		int qimo,banji;
		char ganbu,xibu;
		int lunwen;
		int money;
	};





int suan(struct student *s){
	//1) ????????8000??????????80??>80??
	//?????????1??1?????????????
	int mon=0;
	if (s->qimo >80&&s->lunwen>=1) mon+=8000;
//	2) ????????4000??????????85??>85??????????
	//??80??>80????????? 
   	if (s->qimo >85&&s->banji >80) mon+=4000;
//	3) ????????2000??????????90??>90????????? 
	if (s->qimo >90) mon+=2000;
	//4) ????????1000??????????85??>85????????????? 
	if (s->qimo >85&&s->xibu =='Y') mon+=1000;

//5) ????????850??????????80??>80??????????? 
	if (s->banji >80&&s->ganbu =='Y') mon+=850;
return mon;
}

int main()
{
	
	long int n,sum=0;
	int i;
	char tmp;
	struct student *stu,*max;
	scanf("%d",&n);
	stu=(struct student *)malloc(sizeof(struct student)*n);

	for (i=0;i<n;i++){ //ChenRuiyi 88 78 N Y 1

		scanf("%s%d%d%c%c%c%c%d",stu[i].name,&(stu[i].qimo),&(stu[i].banji),&tmp,&(stu[i].ganbu),&tmp,&(stu[i].xibu),&(stu[i].lunwen));
		stu[i].money=suan(stu+i);
		sum+=stu[i].money;
	}
	max=stu+n-1;
	for (i=n-1;i>0;i--)
		if (max->money<=stu[i].money) max=stu+i;

	printf("%s\n%d\n%d\n",max->name,max->money,sum);




}