#include<cstdio>
#include<cstring>
#include<cstdlib>
struct B
{
int ok;//参赛标记
int num,time,name;// 题数 时间 队名
//int pt;// 罚时
int vis[10][5]; // 题目AC标记 时间 罚时 0 1 2
} a[110];
struct C
{
int time,name,num;
} b[110];
int cmp(const void *a,const void *b)
{
struct C *p = (struct C *) a;
struct C *q = (struct C *) b;
if(p->num==q->num)
{
if(p->time==q->time)
{
return p->name-q->name;
}
return p->time-q->time;
}
return q->num-p->num;
}
int main()
{
int t;
scanf("%d",&t);
getchar();
getchar();
while(t--)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
char xa[110],tj;
int tm,tn,tt,max=-1;
while(gets(xa))
{
if(!strcmp(xa,"")) break;
sscanf(xa,"%d %d %d %c",&tn,&tm,&tt,&tj);
if(max < tn) max = tn;
a[tn].ok = 1;
if(tj=='C'&&!a[tn].vis[tm][0])
{
a[tn].num++;
a[tn].vis[tm][0] = 1;
a[tn].vis[tm][1] = tt;
}
else if(tj=='I'&&!a[tn].vis[tm][0])
{
a[tn].vis[tm][2] += 20;
}
}
int l = 0;
for(int i = 0; i <= max; i++)
{
if(a[i].ok)
{
b[l].name = i;
b[l].num = a[i].num;
for(int j = 1; j <= 9; j++)
{
if(a[i].vis[j][0])
{
b[l].time += a[i].vis[j][1]+a[i].vis[j][2];
}
}
l++;
}
}
qsort(b,l,sizeof(b[0]),cmp);
for(int i = 0; i < l ; i++)
printf("%d %d %d\n",b[i].name,b[i].num,b[i].time);
if(t) printf("\n");
}
return 0;
}
#include<cstring>
#include<cstdlib>
struct B
{
int ok;//参赛标记
int num,time,name;// 题数 时间 队名
//int pt;// 罚时
int vis[10][5]; // 题目AC标记 时间 罚时 0 1 2
} a[110];
struct C
{
int time,name,num;
} b[110];
int cmp(const void *a,const void *b)
{
struct C *p = (struct C *) a;
struct C *q = (struct C *) b;
if(p->num==q->num)
{
if(p->time==q->time)
{
return p->name-q->name;
}
return p->time-q->time;
}
return q->num-p->num;
}
int main()
{
int t;
scanf("%d",&t);
getchar();
getchar();
while(t--)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
char xa[110],tj;
int tm,tn,tt,max=-1;
while(gets(xa))
{
if(!strcmp(xa,"")) break;
sscanf(xa,"%d %d %d %c",&tn,&tm,&tt,&tj);
if(max < tn) max = tn;
a[tn].ok = 1;
if(tj=='C'&&!a[tn].vis[tm][0])
{
a[tn].num++;
a[tn].vis[tm][0] = 1;
a[tn].vis[tm][1] = tt;
}
else if(tj=='I'&&!a[tn].vis[tm][0])
{
a[tn].vis[tm][2] += 20;
}
}
int l = 0;
for(int i = 0; i <= max; i++)
{
if(a[i].ok)
{
b[l].name = i;
b[l].num = a[i].num;
for(int j = 1; j <= 9; j++)
{
if(a[i].vis[j][0])
{
b[l].time += a[i].vis[j][1]+a[i].vis[j][2];
}
}
l++;
}
}
qsort(b,l,sizeof(b[0]),cmp);
for(int i = 0; i < l ; i++)
printf("%d %d %d\n",b[i].name,b[i].num,b[i].time);
if(t) printf("\n");
}
return 0;
}