Problem list
Log in
#coci00176 · COCI 2010/2011 Contest 5

Košarka

Silver III 1.0 s 32 MB

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 \le N \le 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 the 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.

Example 1

Input
1
1 20:00
Output
28:00
00:00

Example 2

Input
3
1 01:10
2 21:10
2 31:30
Output
20:00
16:30

Example 3

Input
5
1 01:10
1 02:20
2 45:30
2 46:40
2 47:50
Output
45:30
00:10
Source
COCI 2010/2011 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code