//MJRT #include #include #include #include ////////////////////// #include #include #include #include #include #include #include /////////////////////// #include #include #include #include #include #include #include using namespace std; #define lch(x) ((x) << 1) #define rch(x) ((x)<<1|1) #define dad(x) ((x)>>1) #define lowbit(x) ((x)&(-x)) static int INDEX = 0,BUGs = 0; #define BUG() cout << "There is BUG No." << BUGs++ <>1; const int N = 5 + 1000; struct P { char name[25]; bool sex; int x,y; double f; bool operator < (const P & a) const { return f > a.f; } }a[N]; int nv = 0,n,m,max_x,max_y; char tmp[N]; int main() { //ios::sync_with_stdio(false); #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif int Case; scanf("%d",&Case); while(Case--) { nv = 0; max_x = max_y = -INF; scanf("%d%d",&n,&m); for(int i = 0 ; i < n ; i++) { scanf("%s%s%d%d",a[i].name,tmp,&a[i].x,&a[i].y); if(tmp[0]=='f') { a[i].sex=0; nv = 1; } else { a[i].sex=1; } max_x = max(a[i].x,max_x); max_y = max(a[i].y,max_y); } double tx = 300.0/max_x , ty = 300.0/max_y; for(int i = 0 ; i < n ; i++) a[i].f = a[i].x*tx*0.3 + a[i].y*ty*0.7; sort(a,a+n); int flag= 0; puts("The member list of Shandong team is as follows:"); for(int i = 0 ; i < m-1 ; i++) { puts(a[i].name);//Whats(a[i].f); if(!a[i].sex) flag = 1; } if(nv && !flag) { for(int i = m-1 ; i < n ; i++) { if(!a[i].sex) { puts(a[i].name);//Whats(a[i].f); break; } } } else { puts(a[m-1].name);//Whats(a[m-1].f); } } return 0; }