Bruno and his friends are playing with water guns. They are passionate gamers, which is why this is not a regular water gun game, but is in fact very similar to video-games. They even hired a moderator for the game.
At the beginning of the game, the players are divided into two teams: pineapples
and blueberries. During the game, the moderator keeps track of every time some
player sprays some other player, writing down the time when it happened. Just like in video-games, the
players acquire points. When a player from some team sprays someone from the opposing team, their
team receives points. However, if within
seconds the same player again sprays someone from the
opposing team, this is counted as a double-spray and their team receives an additional
points. A player
can achieve multiple double-sprays in a row, each worth an additional
points for their team.
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 10 | |
2 | 15 | No double-sprays occur. |
3 | 25 | No additional constraints. |
Input Specification
The first line contains the integer
, the number of sprays that happened during the game.
Each of the following lines contains three integers
which denote that player
sprayed player
at time
(in seconds).
Labels of the players from team pineapple are positive integers from to
, while the labels of the players
from team blueberry are the positive integers from
to
. The players
and
are guaranteed to be from
different teams.
The numbers are distinct and are ordered increasingly.
Output Specification
The first and only line should contain two numbers: the total score of team pineapple and the total score of team blueberry.
Sample Input 1
3
10 1 6
20 1 7
21 8 1
Sample Output 1
250 100
Explanation for Sample Output 1
At seconds and
, player
sprayed players
and
from the other team. For each spraying the pineapples received
points. As the sprays happened within
seconds, the team received an additional
points
. Team blueberries sprayed only one player from the opposing team, which
is why they received only
points.
Sample Input 2
3
10 2 5
15 2 6
25 2 5
Sample Output 2
400 0
Explanation for Sample Output 2
Player achieved two double-sprays in a row, which is why team pineapple got a total of
points.
Sample Input 3
2
10 5 2
11 6 3
Sample Output 3
0 200
Comments