#include #include #include using namespace std; typedef struct team { string name; int price[4]; }team; typedef struct school { string name; int price[4]; team tm[101]; int nowteamlen; }school; typedef struct place { string name; int price[4]; }place; school scl[201]; place plc[201]; int tellprice(string price) { if(price=="gold") return 1; if(price=="silver") return 2; if(price=="copper") return 3; return 0; } int cmpbyscl(const void *a,const void *b) { school *x=(school *)a; school *y=(school *)b; if(x->price[1]price[1]) return 1; if(x->price[1]>y->price[1]) return -1; if(x->price[2]price[2]) return 1; if(x->price[2]>y->price[2]) return -1; if(x->price[3]price[3]) return 1; if(x->price[3]>y->price[3]) return -1; if(x->name>y->name) return 1; if(x->namename) return -1; return 0; } int cmpbytm(const void *a,const void *b) { team *x=(team *)a; team *y=(team *)b; if(x->price[1]price[1]) return 1; if(x->price[1]>y->price[1]) return -1; if(x->price[2]price[2]) return 1; if(x->price[2]>y->price[2]) return -1; if(x->price[3]price[3]) return 1; if(x->price[3]>y->price[3]) return -1; if(x->name>y->name) return 1; if(x->namename) return -1; return 0; } int cmpbyplc(const void *a,const void *b) { place *x=(place *)a; place *y=(place *)b; if(x->name>y->name) return 1; if(x->namename) return -1; return 0; } int main() { int i, j; long T,N,t; long nowplacelen,nowschoollen; string tschool,tteam,tprice,tplace; scanf("%d",&T); for(int pp=1;pp<=T;pp++) { scanf("%d",&N); nowplacelen=0; nowschoollen=0; for(i=0;i>tschool>>tteam>>tprice>>tplace; for(j=0;j