Greedy Gift Givers
A group of uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to some or all of the other friends (although some might be cheap and give to no one). Likewise, each friend might or might not receive money from any or all of the other friends. Your goal is to deduce how much more money each person receives than they give.
The rules for gift-giving are potentially different than you might expect. Each person goes to the bank (or any other source of money) to get a certain amount of money to give and divides this money evenly among all those to whom he or she is giving a gift. No fractional money is available, so dividing among friends would be each for the friends with left over — that left over goes into the giver's "account". All the participants' gift accounts start at and are decreased by money given and increased by money received.
Input
The first line contains number . Each of the next lines contains the name of group member.
Then a description of groups is given. The first line of each group tells the person's name who will be giving gifts. The second line in the group contains two numbers:
The amount of money (in the range ) to be divided into gifts by the giver;
, the number of people to whom the giver will give gifts;
If is nonzero, each of the next lines lists the name of a recipient of a gift; recipients are not repeated in a single giver's list.
Output
Determine and print how much money each person ends up with.