Basketball Lead Time

Time limit1sMemory limit128 MB

Problem

Donghyuk has the scoring log for a basketball game that lasts exactly 48 minutes. Each record tells which team scored and the time of the score.

Given the scoring records for the two teams, find the total amount of time that team 1 and team 2 were each ahead during the game. Time while the score is tied does not count for either team.

Input

The first line contains the number of scores N. (1 <= N <= 100)

Each of the next N lines contains one scoring record in the form team time. The team number is 1 or 2, and the time is written as MM:SS. The minute is between 0 and 47, and the second is between 0 and 59. One-digit values are written with a leading 0, and no two scores occur at the same time.

Output

Print the total time that team 1 was ahead on the first line, and the total time that team 2 was ahead on the second line. Use the MM:SS format.