1 #include<stdio.h>
2 #include<string.h>
3 #include<queue>
4 #include<algorithm>
5 using namespace std;
6 #define bj (b.r1*0.3*ch(x)+b.r2*0.7*ch(y))>(a.r1*0.3*ch(x)+a.r2*0.7*ch(y))
7 #define MAX(x,y)(x>y?x:y)
8 #define ch(x) (300.0/x)
9 int T,n,m,x,y;
10 struct Node{
11 char name[25],sex[10];
12 int r1,r2;
13 friend bool operator < (Node a,Node b){
14 if((b.r1*0.3*ch(x)+b.r2*0.7*ch(y))-(a.r1*0.3*ch(x)+a.r2*0.7*ch(y))>0)return 1;
15 else return 0;
16 }
17 };
18 void getx(Node a){
19 x=MAX(x,a.r1);
20 y=MAX(y,a.r2);
21 }
22 int main(){
23 scanf("%d",&T);
24 while(T--){
25 priority_queue<Node>d1,d2;
26 scanf("%d%d",&n,&m);
27 Node a,b;
28 int girl=0;
29 x=y=0;
30 for(int i=0;i<n;i++){
31 scanf("%s%s%d%d",a.name,a.sex,&a.r1,&a.r2);
32 getx(a);
33 if(!strcmp(a.sex,"male"))d1.push(a);
34 else{
35 d2.push(a);
36 girl=1;
37 }
38 }
39 int temp=0;
40 puts("The member list of Shandong team is as follows:");
41 for(int i=0;i<m-1;i++){
42 a=d1.top();
43 b=d2.top();
44 if(bj){
45 temp=1;
46 d2.pop();
47 puts(b.name);
48 //printf("%.2lf\n",b.r1*0.3*ch(x)+b.r2*0.7*ch(y));
49 }
50 else{
51 d1.pop();
52 puts(a.name);
53 //printf("%.2lf\n",a.r1*0.3*ch(x)+a.r2*0.7*ch(y));
54 }
55 }
56 if(!temp&&girl){
57 b=d2.top();
58 puts(b.name);
59 // printf("%.2lf\n",b.r1*0.3*ch(x)+b.r2*0.7*ch(y));
60 }
61 else{
62 a=d1.top();
63 puts(a.name);
64 // printf("%.2lf\n",a.r1*0.3*ch(x)+a.r2*0.7*ch(y));
65 }
66 }
67 return 0;
68 }