P7632 [COCI 2010/2011 #5] KOŠARKA

Description

Slavko has started following the NBA. A game lasts exactly $48$ minutes. After a game ends, statistics are shown. Every time a team scores, Slavko writes it down. He is curious about how long each team stays in the lead.

Input Format

The input consists of $N$ lines. The first line contains an integer $N$, the number of events. The next $N$ lines describe the moments when a team scores. Each line contains the team that scored ($1$ or $2$) and a time. The time format is $MM:SS$. If the minutes or seconds are $\le 9$, they are padded with a leading $0$.

Output Format

The first line outputs the total time during which Team $1$ is in the lead. The second line outputs the total time during which Team $2$ is in the lead. All durations should be in $MM:SS$ format, with leading zeros.

Explanation/Hint

**Sample Explanation #1** Team $1$ scores a point at exactly $20$ minutes, making the score $1:0$, and takes the lead. During the next $28$ minutes, Team $2$ does not score, so Team $1$ keeps the lead the whole time. **Constraints** For $100\%$ of the testdata, $1 \le N \le 100$, $0 \le$ minutes $\le 47$, $0 \le$ seconds $\le 59$. **Notes** The score for this problem follows the original COCI settings, with a full score of $50$. Translated from [COCI2010-2011](https://hsin.hr/coci/archive/2010_2011/) [CONTEST #5](https://hsin.hr/coci/archive/2010_2011/contest5_tasks.pdf) _**T2 KOŠARKA**_. Translated by ChatGPT 5