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

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

hide comments
2012-12-07 18:48:26 Robert Milija¹
Watch out! Make sure that you print ALL THE ZEROES!
Input:
3
1 01:00
2 20:00
2 47:56

Output:
19:00
00:04
2012-09-30 12:59:12 DEVANSH PARASHAR
some problem in judge 12
edit>>finally a green light for those who are stuck at judge 12 read and try to understand the format of output carefully and then evaluate the range of output


Last edit: 2012-09-30 19:15:06
2012-08-27 14:36:55 vishal chaudhary
Is something wrong with the 12th case , i got WA too in 12th case...
2012-07-13 18:15:03 temerario
WA at 12th test case...Help me plz..
2012-07-08 15:50:39 aman garg
char a[100][10];
scanf("%d",&n);

for(i=0; i<n; i++)
scanf("%[^\r\n]s",a[i]);

i dont know what is the problem but it is not working(not taking the input)
2012-04-02 04:28:21 fitcat
"the first team was in the lead" should be interpreted as "team 1 was in the lead" and similarly "second team" should be "team 2".
I interpreted it as the first team who took the lead...
2012-02-09 13:21:20 saket diwakar
finally got AC...
easy but tricky...
running judge is only for 11th and 12th case...
2012-01-13 16:13:14 BOND
caution : check at time 0 and alternative/consecutive occurrences of teams...
2011-12-10 16:47:37 Zhiang
easy...:)
but tricky....^_^
2011-12-10 11:16:26 prachi sharma
any special case??? m getting wa after running 17 cases.......
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.