CVJETICI | 프로그래밍의 벗 PivotOJ
PivotOJ

CVJETICI

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2009 Regional Competition - SeniorsBOJ 2934
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

On a faraway planet, strange plants with two stems can be found. Every plant on the planet can be described by three numbers: the x-coordinates of the stems L and R, and the height H at which the stems are connect. The image depicts a plant with L=2, R=5 and H=4. 

[이미지 1]

Every day a new plant grows on the planet. The plant that grows on day 1 is of height 1, and every subsequent plant is one higher than the previous one. 

When a stem of a new plant intersects the horizontal segment of another plant, a small flower grows (if one wasn't there already). If segments merely touch in a point, a flower will not grow there. 

The following images are a visualization of the first example on the next page. 

[이미지 2]

Write a program that, given the coordinates of all plants, calculates the number of new flower every day. 

입력

The first line contains an integer N (1 ≤ N ≤ 100 000), the number of days. 

Each of the following N lines contains two integers L and R (1 ≤ L < R ≤ 100 000), the coordinates of the stems of a plant. 

출력

Output N lines, the number of new flowers after each plant grows.

예제

예제 1

입력
4
1 4
3 7
1 6
2 6
출력
0
1
1
2

예제 2

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