PivotOJ

Justice Served

시간 제한: 5000ms메모리 제한: 1024MB출처: NWERC 2022BOJ 26183

문제

You finally managed to produce the ultimate stroopwafel with just the right number of squares on it. After the hard work, you left the stroopwafel unattended for a few seconds to get yourself a hot drink. Full of anticipation for your delicious treat, you came back just to see that your stroopwafel was gone! Even though you were only away for a short time, someone used the opportunity to steal it.

You looked at the security recordings and saw a total of nn suspects that had been in the room where you left your stroopwafel, each entering and leaving the room exactly once. After seeing this, you already had a good idea who took it since your archrival Rob -- who has some background in robberies -- was among the suspects. But you wanted to give him the benefit of the doubt and decided to interrogate every suspect. Unsurprisingly, every suspect claimed their own innocence. However, some suspects also provided an alibi for other suspects. Specifically, a suspect AA provided an alibi for suspect BB if and only if AA was in the room for the entire duration BB was in the room.

You feel like a suspect is more convincing if they have an alibi provided by a suspect who is convincing themselves. Formally, a suspect without an alibi has convincingness 00. Otherwise, their convincingness is 11 more than the convincingness of the most convincing suspect who provides them with an alibi. Your task is to compute the convincingness of each suspect.

입력

The input consists of:

  • One line with a single integer nn (1n21051\leq n\leq 2\cdot 10^5), the number of suspects.
  • nn lines, each with two integers aa and tt (1a,t1091\leq a,t\leq 10^9), the time at which each suspect arrived and the duration they stayed.

It is guaranteed that no two suspects who arrived at the same moment stayed for the same duration.

출력

Output the convincingness of each suspect.

예제

예제 1

입력
4
2 8
1 7
4 5
5 2
출력
0 0 1 2

예제 2

입력
5
2 4
3 3
2 2
4 2
4 1
출력
0 1 1 2 3
코드를 제출하려면 로그인하세요.