#K53602. Wonderland Time Calculation

    ID: 29568 Type: Default 1000ms 256MiB

Wonderland Time Calculation

Wonderland Time Calculation

In Wonderland, time is represented on a 12-hour clock where hours range from 0 to 11 and minutes from 0 to 59. Given the current time H:M and a non-negative integer N representing minutes to add, your task is to compute the new time after adding N minutes. Note that the hour should wrap around using modulo 12 arithmetic. For example, adding 15 minutes to 11:50 results in 0:05.

Formally, if the current time is (H) hours and (M) minutes, the total minutes from midnight is (T = 60H + M). After adding (N) minutes, the new time is given by:
[ \text{New Hour } = \left(\frac{T + N}{60}\right) \mod 12, \quad \text{New Minute } = (T + N) \mod 60 ] Your program should read input from stdin and output the result to stdout.

inputFormat

The first line of input contains an integer (T) representing the number of test cases. Each of the next (T) lines contains three integers (H), (M), and (N) separated by spaces, where (H) (0 (\leq) (H) (\leq) 11) is the hour, (M) (0 (\leq) (M) (\leq) 59) is the minute, and (N) is the number of minutes to add.

outputFormat

For each test case, output the new time in the format of two integers separated by a space: the new hour and the new minute. Each result should be printed on a new line.## sample

3
10 30 40
0 15 60
11 50 15
11 10

1 15 0 5

</p>