#include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define ABS(a) (((a) > (0)) ? (a) : (-(a))) using namespace std; struct Member { string name, sex; double r1, r2, fin; bool operator <(const Member &a) const { return fin > a.fin; } } member[105]; int main() { int t, n, m, ind; double mx1, mx2, mx; scanf("%d", &t); while(t--) { scanf("%d%d", &n, &m); mx1 = mx2 = -1; for(int i = 0; i < n; i++) { cin >> member[i].name >> member[i].sex >> member[i].r1 >> member[i].r2; mx1 = max(mx1, member[i].r1); mx2 = max(mx2, member[i].r2); } mx = -1; for(int i = 0; i < n; i++) { member[i].fin = 0.3 * (member[i].r1 * 300.0 /(double) mx1) + 0.7 * (member[i].r2 * 300.0 /(double) mx2); if(member[i].sex == "female") { if(member[i].fin > mx) { mx = member[i].fin; ind = i; } } } printf("The member list of Shandong team is as follows:\n"); bool flag = true; if(mx != -1) { swap(member[n - 1], member[ind]); n--; flag = false; } sort(member, member + n); if(!flag) { member[m - 1] = member[n]; sort(member, member + m); } for(int i = 0; i < m; i++) cout << member[i].name << endl; } return 0; }