#include<stdio.h> #include<string.h> int main() { struct { char name[250]; int qm; int by; char gb; char xb; int lw; } xx[205]; int jxj[105],n,i,s,k,m; scanf("%d",&n); { while(n--) { memset(xx,0,sizeof xx); memset(jxj,0,sizeof jxj); scanf("%d",&m); for(i=s=k=0; i<m; ++i) { scanf("%s%d%d %c %c %d",xx[i].name,&xx[i].qm,&xx[i].by,&xx[i].gb,&xx[i].xb,&xx[i].lw); if(xx[i].qm>80 && xx[i].lw>0) jxj[i]+=8000; if(xx[i].qm>85 && xx[i].by>80) jxj[i]+=4000; if(xx[i].qm>90) jxj[i]+=2000; if(xx[i].qm>85 && xx[i].xb=='Y') jxj[i]+=1000; if(xx[i].by>80 && xx[i].gb=='Y') jxj[i]+=850; if(jxj[i]>jxj[k]) k=i; s+=jxj[i]; } //for(i=0; i<m; ++i) // printf("%s* %d* %d* %c* %c* %d* ",xx[i].name,xx[i].qm,xx[i].by,xx[i].gb,xx[i].xb,xx[i].lw); printf("%s %d %d ",xx[k].name,jxj[k],s); } } }