Honest politicians

In a distant country, judges are busy trying to find out how much money several politicians have earned as the result of some money movements. There are three kinds of transactions:

Could you please compute the final earnings of every politician?

Input

Input consists of several cases. Each case begins with a natural number rr. Follow between 1 and 10410^4 transactions. Every case ends with “END”. You can assume that rr is between 1 and the number of different names in the case, that all the names are strings made up of an uppercase letter followed by between 1 and 10 lowercase letters, and that all given numbers are natural numbers between 1 and 10510^5.

Output

For every case, print rr rows with the name and the final money of every politician. Names should be alphabetically sorted by columns. Every column has to be as narrow as possible, with names aligned to the left, money aligned to the right, and at least one space separating them. Separate columns with a vertical bar surronded by two spaces. The last column may be partially empty: always leave those empty positions at the bottom of the column. Print a line with 40 ‘’ after every case. Take a look at the sample output to exactly follow its format. Note that no line should end with any space.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:49:21.688Z

© Jutge.org, 2006–2026.
https://jutge.org