我不李姐:
#include<bits/stdc++.h>
#define bug cout<<"bug"
#define ll long long
#define ull unsigned long long
using namespace std;
map<string,map<string,int> >mp;
string j2,j3;
int n,j4;
int q;
int main() {
scanf("%d",&q);
while(q--) {
scanf("%d",&n);
for(int i=0; i<n; ++i) {
cin>>j3>>j2>>j4;
mp[j3][j2]+=j4;
}
map<string,map<string,int> >::iterator it=mp.begin();
for(; it!=mp.end(); ++it) {
cout<<it->first<<endl;
map<string,map<string,int> >::iterator it2=(it->second).begin();
for(; it2!=(it->second).end(); ++it2) {
cout<<" |----"<<it2->first<<"("<<it2->second<<")"<<endl;
}
}
m.clear;
printf("\n");
}
return 0;
}