MIDO - KOSARK


Slavko has started to follow the NBA league. The game duration is exactly 48 minutes. When a game ends, the statistics are shown. Slavko has written down whenever a team scored. He is curious about how long each team was in the lead.

Input

The first line of input contains one integer N (1 ≤ N ≤ 100). The following N lines describe events when a team scored. Each description consists of a team that scored, which is either 1 or 2, and a timestamp in format MM:SS (minutes:seconds), the time when a team scored. Minutes and seconds are zero padded and from ranges [00, 47] and [00, 59] (inclusive). The given timestamps are unique.

Output

The first line of output must contain the duration that the first team was in the lead.

The second line of output must contain the duration that the second team was in the lead.

All durations should be in MM:SS format, with leading zeros.

Sample

Input
3
1 01:10
2 21:10
2 31:30

Output 
20:00
16:30

hide comments
Prakhar Jain: 2011-11-30 19:32:30

easy one.....:)

Andy: 2011-11-04 05:32:23

are times given always in order?

Anil Purohit: 2011-10-29 17:11:10

Finally...AC :)

Khairy: 2011-09-11 17:15:59

Are times given in order ?

impulse: 2011-07-12 10:06:33

LOL ,AC!!!

manish kapoor: 2011-05-19 10:44:10

finally AC

Last edit: 2011-05-19 11:32:37
Kasprov: 2011-05-10 04:49:17

will only one set of input be provided??
if not how does the program terminate??

HELLO: 2011-03-27 12:36:23

good question

The Champ: 2011-02-20 18:18:54

team-2 was in lead since its first goal which was at time 21:10 because after that timestamp team-1 did not goal. and thus lead time for team-2 should have been from 21:10 till 47:59 than why it is 16:30 only instead of 26:50

When 2 scores at 21:10, the score is 1-1. So 2 is not in lead. 2 is in lead only when he scores at 31.30 (when the score is 1-2).

Last edit: 2011-02-21 04:32:09
Piotr KÄ…kol: 2011-02-20 18:01:15

It means that minutes are from 0 to 47 (inclusive) and seconds from 0 to 59 (inclusive).


Added by:Kawmia Institutes
Date:2011-02-16
Time limit:0.209s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:COCI