Know your Pounds, Shillings, and Pence
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds
Mrs Pennyfeather has been awoken from her cryogenic nap and is totally bewildered at the ignorance of youth. They don’t know how to add in Pounds, Shillings, and Pence!!!!
- Pence use base 12. In other words, 13 pence is equal to 1 shilling and 1 penny because there are 12 pence to a shilling.
- Shillings use base 20. That is, there are 20 shillings in a pound. So 22 shillings is 1 pound and 2 shillings.
- Pounds are base 10 and are preceded with the symbol £. However, we will use # (a hash) in its place.
Your job is to show Mrs Pennyfeather that some youth are actually pretty smart by asking her for 2 or more amounts in pounds, shilling, and pence and telling her the total. She is going to give you different sums to do. The sum should be obtained by changing as many pence for shillings as possible (and shillings for pounds too).
Input
The first line contains a whole number (called N). This represents the total number of sums to be done.
Each sum will have a first line containing a whole number S. There follow S lines, each line is of the form #X-Y-Z
. That is; a pounds symbol (#), followed by a whole number of pounds (X), a dash, a whole number of shillings (Y) and another dash followed by a whole number of pence (Z). it is guaranteed that Y \lt 20 and Z \lt 12.
Output
For each of the N sums, print the answer using the same currency format as the input. i.e. Print a #, followed by the number of pounds, a dash, a number of shillings, and another dash followed by the number of pence (see the examples).
You are guaranteed that 1 \le N \le 10 and 2 \le S \le 10.
Subtasks
- Subtask 1 (10%): Write a solution where N=1 (that means there is only one sum to do) and S=2. Additionally, all Z’s in a sum add to less than 12 and all Y’s in a sum add to less than 20.
- Subtask 2 (40%): We guarantee that N=1 and S = 2.
- Subtask 3 (50%): You get the remaining 50% for the full solution.
-
Sample Input 1
1 2 #1-1-1 #1-1-1
Sample Output 1
#2-2-2
-
Sample Input 2
1 3 #3-9-8 #1-18-11 #17-19-10
Sample Output 2
#23-8-5