Hide

Problem I
Prime Time

/problems/primetime/file/statement/en/img-0001.jpg

Odd and Even have had their share of fun times playing the good old prime game:

They start with an arbitrary natural number, and take turns either adding $1$ or dividing by a prime (assuming the result is still a natural number), and the one to reach $1$ is the winner. However, now that they have a new friend, Ingmariay, they have decided to expand the rules of the game to allow for three-player action:

Instead of determining a winner for each round of play, they instead score points; the lowest number each of them has claimed during the round is the amount of points they get. (If any of them did not have the opportunity to claim any numbers, the starting number will be their score for that round.) At the end of the day, the player with the fewest points wins. And to avoid bad blood between themselves, they have all agreed that each of them only will focus on minimizing their own scores, and that whenever a player can choose different numbers that will result in the same score, that player will choose the lowest of those numbers. They have also agreed on a fixed order of play: Odd $\rightarrow $ Even $\rightarrow $ Ingmariay $\rightarrow ...$, but they alternate who gets to start.

You recently missed one of their exciting evenings of play, because you had to make problems for the NCPC event. Fortunately for you, they had recorded the numbers and starting players for each round, and told you that since they always play optimally (minimizing their own score), you could use this to simulate the event for yourself. Oh joy!

As an example round, assume that Even is chosen as the starting player, and with the starting number $15$. Then Even claims $16$, Ingmariay $8$, Odd $4$, Even $2$ and Ingmariay $1$. Odd gets $4$ points, Even $2$ and Ingmariay $1$.

Input

The first line of input contains a single integer $n$ ($1 \leq n \leq 1\, 000$), the number of rounds they played that evening.

Then follow $n$ lines each beginning with the first character of the name of the starting player (either ’O’, ’E’ or ’I’), followed by a space and then the starting number for that round, in the range $[1, 10\, 000]$

Note: If the starting number is $1$, all players receive $1$ point for that round.

Output

Output a single line with the score at the end of the day for each of the three contestants, in the order “Odd”, “Even”, “Ingmariay”.

Sample Input 1 Sample Output 1
1
O 4
2 1 4
Sample Input 2 Sample Output 2
3
O 13
I 14
E 15
6 29 16

Please log in to submit a solution to this problem

Log in