Segments#5156

Segments

1 secondo
128 megabyte
Molto facile

No two letters should have a common point. As well as the general dash

Guide for telegraphists

The director of the Institute of Segment Geometry (ISG) invited Aaz to his office. Judging by the environment, the institution was not in poverty. But the problem at this time was different.

We are not without work. Every season after the start of the programming championship, we solve a lot of problems about the intersection of two segments at the request of competition organizers. But it is still routine, and employees begin to lose interest. In some places, some are even involved in amateur performances—organizing accordion concerts by candlelight—instead of working. Can you formulate a problem for us, different from this but not very far from it in formulation?

For example... Given segments on a line. For each segment, find the number of other segments that have at least one point in common with it.

ISG staff enthusiastically took up the task. Moreover, they instructed you to write a program to solve it.

Input

The input contains multiple test cases. The first line of each test case contains the number of segments (1 \le n \le 10^5). Each of the next lines describes a segment: the -th line contains two integers L_i and R_i — the start and end coordinates of the -th segment (-10^9 \le L_i \le R_i \le 10^9).

The total sum of over all test cases does not exceed 10^5. The input terminates with a zero. The number of test cases does not exceed 10^4.

Output

For each test case, print in one line numbers as shown in the sample: for each segment, output the number of segments with which it has at least one common point, not counting itself.

Follow the output format as closely as possible.

Esempi

prb5156.gif

Esempio 1

Loading
Loading