The siblings Dewey, Huey, and Louie Duck each got $100 from Scrooge McDuck. Being generous siblings, they give each other money on many occasions. However, since they often stuff their change in any pocket they can find (which has caused the washing machine to misbehave on more than one occasion), they have no clue how much money they actually have. Their uncle Donald suggested them to take a course on programming at the University of Oregan, where Donald is college football's most lovable mascot, so that they could develop an app to keep track of their money. However, Dewey, Huey, and Louie prefer to indulge themselves in the activities of the Junior Woodchucks (and let's not fool ourselves, wouldn't you if you ever got a chance?). As a result, you are asked to develop the app.
n gave m dwhere n and m are names consisting of 2 to 10 characters and 1 <= d <= 20. These lines are followed by q lines of queries, each containing a name consisting of 2 to 10 characters.
2 5 3 Huey gave Dewey 10 Dewey gave Louie 8 Huey gave Louie 12 Louie gave Dewey 5 Louie gave Huey 3 Dewey Huey Louie 2 5 Eider gave Quackmore 50 Eider gave Quackmore 50 Eider Daphne Eider Quackmore Eider
107 81 112 0 100 0 200 0