1 //#include<bits/stdc++.h> 2 #include<map> 3 #include<cstdio> 4 #include<string> 5 #include<iostream> 6 using namespace std; 7 int main(){ 8 int N; 9 scanf("%d",&N); 10 while(N--){ 11 int M; 12 scanf("%d",&M); 13 map<string ,map<string,int> > mp; 14 while(M--){ 15 char city[90],kind[90]; 16 int qty; 17 scanf("%s%s%d",kind,city,&qty); 18 mp[city][kind]+=qty; 19 } 20 for(map<string,map<string,int>>::iterator it1=mp.begin();it1!=mp.end();++it1){ 21 cout<<it1->first<<endl; 22 for(map<string,int>::iterator it2=it1->second.begin();it2!=it1->second.end();++it2){ 23 cout<<" |----"<<it2->first<<"("<<it2->second<<")"<<endl; 24 } 25 } 26 if(N!=0) cout<<endl; 27 } 28 return 0; 29 }