logo AlgoBeat OnlineJudge
登录 注册

#206191. [NWRRC 2016] CodeCoder vs TopForces

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Competitive programming is very popular in Byteland. In fact, every Bytelandian citizen is registered at two programming sites -- CodeCoder and TopForces. Each site maintains its own proprietary rating system. Each citizen has a unique integer rating at each site that approximates their skill. Greater rating corresponds to better skill.

People of Byteland are naturally optimistic. Citizen A thinks that he has a chance to beat citizen B in a programming competition if there exists a sequence of Bytelandian citizens for some such that for each has higher rating than at one or both sites.

Each Bytelandian citizen wants to know how many other citizens they can possibly beat in a programming competition.

输入格式

The first line of the input contains an integer -- the number of citizens . lines contain information about ratings. The i-th of them contains two integers -- ratings of the i-th citizen at CodeCoder and TopForces All the ratings at each site are distinct.

输出格式

For each citizen output an integer -- how many other citizens they can possibly beat in a programming competition. Each should be printed in a separate line, in the order the citizens are given in the input.

样例

样例输入 1

4
2 3
3 2
1 1
4 5

样例输出 1

2
2
0
3

数据范围与提示

Time limit: 2 s, Memory limit: 256 MB.