410732: GYM104094 H One-dimensional Game

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. One-dimensional Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Bogdan is playing a game. The game is one-dimensional — there are $$$n$$$ platforms located on the horizontal line. Bogdan can move between platforms. The $$$i$$$-th platform is a horizontal segment $$$[l_i, r_i]$$$. All segments are distinct.

Let's say that the platform $$$j$$$ is inside the platform $$$i$$$ if $$$l_i \le l_j$$$ and $$$r_j \le r_i$$$.

At the beginning of the game, Bogdan chooses the platform from which he will start his journey. Moving between platforms is dangerous and Bogdan tries to stay away from the danger, so he can move from the platform $$$i$$$ to the platform $$$j$$$ only if the platform $$$j$$$ is inside the platform $$$i$$$ and there is no other platform $$$k$$$, which is inside the platform $$$i$$$ and the platform $$$j$$$ is inside the platform $$$k$$$.

For each platform Bogdan wants to know how many different paths he can take, starting from this platform and ending on any other. To paths are different if there is a platform, which is in the one of the paths but not in the other one.

Help Bogdan count the number of paths from each platform. Since the number of paths can be very large, find it modulo $$$10^9 + 7$$$.

Input

The first line contains the only integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of platforms.

The next $$$n$$$ lines contains the platforms' data, the $$$i$$$-th of these lines contains two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$) — the ends of the $$$i$$$-th segment of the platform.

Output

Print $$$n$$$ integers, the $$$i$$$-th integer must be equal to the number of different paths from the platform $$$i$$$, modulo $$$10^9 + 7$$$.

ExamplesInput
5
1 5
1 4
1 3
1 2
1 1
Output
5 4 3 2 1
Input
4
3 3
1 4
1 5
2 5
Output
1 2 5 2

加入题单

算法标签: