#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, i, k = 1;
while(cin >> n)
{
if(k > 1)
cout << "\n";
map<string, int>mp;
string a[n+1];
string ch;
for(i=1; i<=n; i++)
{
cin >> ch;
a[i] = ch;
mp[ch] = 0;
}
int tk, t, r, p;;
for(i=1; i<=n; i++)
{
cin >> ch >> tk >> t;
if(tk != 0 && t != 0)
{
r = tk % t;
p = tk - r;
mp[ch] = mp[ch] - p;
p = p/t;
}
else
p = 0;
string ar;
for(int j=1; j<=t; j++)
{
cin >> ar;
mp[ar] = mp[ar] + p;
}
}
for(i=1; i<=n; i++)
{
ch = a[i];
cout << ch << " " << mp[ch] << "\n";
}
k++;
}
return 0;
}
Comments
Post a Comment