P28853 [洛谷] [COCI 2014-2015#3] COCI
提高
题目描述

Problem Description

Translated from COCI 2014/2015 Contest 3 T4 "COCI"

The third round of COCI is here! To estimate scores, we hypothesize that if contestant A scored higher than contestant B in both of the first two rounds, then contestant A's score in the third round will be at least equal to contestant B's score.

In each round (including this one), contestants will score at least 0 points and at most 650 points. On the overall leaderboard, contestants will be ranked in descending order based on their total scores from the three rounds. If two contestants have the same score, they will share the same rank, and the next contestant with a lower score will have a subsequent rank. For example, if there are 5 contestants with total scores of 1000, 1000, 900, 900, and 800, their respective ranks will be No. 1, No. 1, No. 3, No. 3, and No. 5.

For each of the N contestants, we know their scores from the first and second rounds. Based on the above assumption, determine the highest and lowest possible ranks each contestant can achieve after the three rounds of COCI.

Input Format

The first line contains an integer \( N (1 \le N \le 5 \times 10^5) \), representing the number of contestants.

The following \( N \) lines each contain two integers within the range \([0, 650]\), representing the scores of each contestant in the first and second rounds.

Output Format

For each contestant, output one line containing two integers, representing the highest and lowest possible ranks they can achieve.

Sample Input and Output

Sample Input #1

5
250 180
250 132
220 123
132 194
220 105

Sample Output #1

1 3
1 3
3 5
1 5
3 5

Sample Input #2

10
650 550
550 554
560 512
610 460
610 456
650 392
580 436
650 366
520 456
490 456

Sample Output #2

1 4
1 8
2 8
2 7
2 9
1 10
4 10
1 10
5 10
5 10

Notes

\( 1 \le N \le 5 \times 10^5 \), all contestant scores are within the range \([0, 650]\).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 250 180 250 132 220 123 132 194 220 105
样例输出
1 3 1 3 3 5 1 5 3 5