1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 #include <map> 7 using namespace std; 8 9 #define GI ({int _t; scanf("%d", &_t); _t;}) 10 #define FOR(i, a, b) for (int i=a; i<b; i++) 11 #define REP(i, a) FOR(i, 0, a) 12 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 13 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 14 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 15 16 17 int main() { 18 int cnt; 19 bool first = true; 20 while (cin >> cnt) { 21 if (first == false) printf("\n"); 22 first = false; 23 int user_cnt = 0; 24 map <string, int> amount; 25 vector <string> lookup; 26 REP(i, cnt) { 27 string t; cin >> t; 28 lookup.push_back(t); 29 amount[t] = 0; 30 } 31 REP(i, cnt) { 32 string from, to; 33 int given, count, taken; 34 cin >> from >> given >> count; 35 REP(j, count) { 36 cin >> to; 37 taken = (given/count); 38 amount[to] += taken; 39 amount[from] -= taken; 40 } 41 } 42 REP(i, cnt) { 43 printf("%s %d\n", lookup[i].c_str(), amount[lookup[i]]); 44 } 45 } 46 return 0; 47 }