#include<iostream> #include<map> #include<string> using namespace std; int main() { int N, M; int i,j,k; string name, place; int value; scanf("%d", &N); while(N--) { map<string,map<string, int> > str; //先按地点,第一个string排序插入,之后按照第二个string名称排序插入// map<string,map<string, int> >::iterator it; map<string,int>::iterator iw; scanf("%d", &M); for(i = 1; i <= M; i++) { cin >> name >> place >> value; str[place][name] += value; } for(it = str.begin(); it != str.end(); it++) { cout << it->first <<endl; for(iw = it->second.begin(); iw != it->second.end(); iw++) { cout<<" |----"<<iw->first<<"("<<iw->second<<")"<<endl; } } if(N != 0) cout << endl; } return 0; }