GAT - Galvin and Time

no tags 

One day, unfortunately Galvin's car was broken down, so he has to move from one place to another place on his legs either by walking or running. While walking (W) his speed is 8 km/hr and while running (R) his speed is 10 km/hr. While travelling from one place to another he can walk, run or both but exactly for 5km each i.e he can walk or run continuously for exactly 5 km, after each 5km he take rest which is of negligible time.

For example, suppose you have sequence of operation (R or W) given: WRRW. Now Galvin walk for 5km then take rest, then run for 5km then take rest and again run for 5km then take rest, and finally walk for 5km.

You are given distance (D) between two places and time (in 24 hour format) at which he started his journey.

Your task is to output the Time at which he reaches his destination (Consider any place as his starting and destination place). Time should be in 24 hour format (00:00:00--23:59:59).

Input

First line of Input contains number of test cases T (T <= 100).

Each test case contain two lines: 1st line contain Distance D (5 <= D <= 500000, always divisible by 5). Time at which he started his journey and 2nd line contain a sequence of operation ("W" or "R").

Output

For each test case print a string "Case #i: "(i is test case number) followed by "Time" (in 24 hour format) at which he reaches his destination.

Example

Input:
2
10 23:59:59
RW
20 19:10:05
RWWR Output: Case #1: 01:07:29 Case #2: 21:25:05

hide comments
Francky: 2014-04-17 23:06:26

This is a tutorial task. Moved.


Added by:P_Quantum
Date:2014-04-17
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Own