#000133

O-rowers

Mina, Anja and Teodora are young programmers. One kind of their preparation for next season of programming competition in Sombor Gimnazium is paddling on water streams or canals in neighborhood. No rules about distance they make on one day. That depends on wind speed, water stream speed and time of day which they spend paddling. If positive, water stream speed helps rowers but makes them slower if it is negative. Wind helps if it blows to their backs but makes them slower if it blows from front side. Every rower paddles with same strength.


Image: veslaci

InputIn first row on standard input is integer D, ( 1 <= D <= 365 ) number of days, which Mina, Anja and Teodora spend paddling.
In next D rows are data for paddling conditions for each day: 7 integers separated with space and short text on end. These are: hours, H (0 <= H < 24), minutes M (0 <= M < 60) and seconds S (0 <= S <= 60); Number od Rowers, N (1 <= N <= 3), their speed Bn, (0 <= Bn <= 10), water stream speed Br, (-10 <= Br <= 10), wind speed Bv, (0 <= Bv <= 10), and Wind direction: front or back. All speeds are in meters per second.

OutputIn one and only row of output write how many kilometers and meters they made in total. Output format is ”[-](X km Z m)” where X and Z are integers and sign is optional if they go backward.
NOTICE: between numbers and measure units on output is exactly one space.

input:

1
8 15 30 2 1 1 1 front

output:

(59 km 460 m)


input:

2
6 0 0 3 0 1 0 back
7 0 0 1 3 0 4 front

output:

-(3 km 600 m)



Second example:
First day they are not paddling at all for 6 hours and water stream brings them 1 m/s, and wind doesn’t blow. (+21600 m)
Second Day, one of three rowers was paddling alone with speed of 3m/s but front wind was pushing him backwards by 4m/s. So boat went back (-25200 m).
In total this is -3600 m.


Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.