True friends always take care of each other
Problem
Stitch is always ready to share a piece of cake with a friend, help Lilo build the best sandcastle and cook breakfast for the whole family. Take an example :)
Stitch loves to cook. The residents liked his dishes so much that they began to place orders. While cooking, Stitch mutters each order under his breath, namely the name of the dish and the quantity he needs to cook for a particular order. You need to help Stitch and sum up the results: for each dish, determine the total amount that needs to be cooked.
Input
Each line contains the name of the dish, followed by a space followed by the quantity (a natural number not exceeding 500000). The last line contains the single word "END!" - a sign of the end of input.
Imprint
Print all the dishes in lexicographical order, then, separated by a space, print the total number that Stitch needs to cook.
Examples
# |
Input |
Output |
1 |
Yapper 10
Yapper 5
Clip 9
Clip 8
Yapper 1
END! |
Clip 17
Yapper 16 |