시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB23201789.474%

문제

The moment has finally arrived. Not only is it the last round of COCI this season, it is also the last round of COCB - the Croatian Open Competition in Beekeeping. Not many people know that the two competitions share the same scoring system. More precisely, both competitions consist of six rounds, the points on each round are between 0 and 500, and the scores of the individual rounds are summed up for the final tally.

After the six rounds, the competitors are ranked based on their total score over the six rounds. If two competitors have the same score, the one with the lexicographically smaller name appears sooner on the ranking. No two competitors have the same name.

The beekeepers are very impatient and they would like to know what their final ranking will be in advance. Each beekeeper wants to know their best and worst possible positions on the final ranking. Unlike skilled COCI programmers, the beekeepers don’t know how to code. Therefore, they are asking you to determine the range of positions they could occupy after the sixth round.

입력

The first line contains a positive integer $n$ ($1 ≤ n ≤ 500$), the number of beekeepers.

Each of the following $n$ lines contains the name of a beekeeper $s_i$ ($1 ≤ |s_i| ≤ 10$) and five numbers $b_{i1}$, $b_{i2}$, $b_{i3}$, $b_{i4}$, $b_{i5}$ from the range $[0, 500]$, the scores of the $i$-th beekeeper on the first five rounds of COCB. The names of the beekeepers are distinct and are made up of at most ten lowercase letters of the latin alphabet.

출력

Print $n$ lines. In the $i$-th line print the best and worst possible position on the ranking for the $i$-th beekeeper.

서브태스크

번호배점제한
110

$n = 2$

240

No additional constraints.

예제 입력 1

3
pavel 120 200 300 400 500
keko 150 400 300 200 100
bartol 470 120 90 93 189

예제 출력 1

1 2
1 3
2 3

예제 입력 2

2
ante 275 275 275 275 275
mate 25 100 175 250 325

예제 출력 2

1 1
2 2

힌트

Clarification of the second example: So far, Ante has a sum of 1375, and Mate has 875. If Mate were to win 500 points on the last round, and Ante 0, the result would be tied and they would both have 1375 points. However, since Ante is lexicographically smaller than Mate, Ante will still be ahead on the ranking.

채점 및 기타 정보

  • 예제는 채점하지 않는다.