QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 10

#1384. Miny [B]

Statistics

On the military training ground in Byteburg, $n$ landmines have been brought and placed in a straight line. Each mine is located at a different position and has its own blast radius. When a mine is detonated, it automatically triggers the detonation of all mines within its blast radius that have not yet exploded. We say that mine $a$ is within the blast radius of mine $b$ if the distance between them is no greater than the blast radius of mine $b$.

Sergeant Bajtomir wants to conduct an experiment. He will choose any subset of mines (possibly empty) and order them to be manually detonated at the same moment. The result of the experiment is the set of mines that exploded—whether due to manual detonation or as a result of another mine's explosion.

How many possible experiment results can Bajtomir obtain? Two experiment results are considered the same if the same set of mines exploded in both. Since the result can be large, output it modulo $10^9 + 7$.

Input

The first line of input contains a natural number $n$ ($1 \le n \le 300\,000$) representing the number of mines. Each of the following $n$ lines contains two natural numbers $a_i$ and $r_i$ ($0 \le a_i \le 10^{18}$, $0 \le r_i \le 10^{18}$) representing the position of the $i$-th mine on the line and its blast radius, respectively. You may assume that $a_1 < a_2 < a_3 < \dots < a_n$.

Output

Output the number of different experiment results Bajtomir can obtain after manually detonating a chosen subset of mines, modulo $10^9 + 7$.

Examples

Input 1

4
0 2
2 0
3 2
7 4

Output 1

7

Note

There are 7 different experiment results that can be obtained: result {} (empty set), if we do not manually detonate any mine; result {1, 2} (mines 1 and 2), if we manually detonate only mine 1; result {1, 2, 3}, if we manually detonate mines 1 and 3; result {1, 2, 3, 4}, if we manually detonate mines 1 and 4; result {2}, if we manually detonate only mine 2; result {2, 3}, if we manually detonate only mine 3; * result {2, 3, 4}, if we manually detonate only mine 4.

Note that the same experiment result can often be obtained in several different ways – for example, the result {1, 2} is also obtained if we manually detonate mines 1 and 2.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.