beecrowd | 3114

Parkour

By Francisco Elio Parente Arcos Filho, UEA BR Brazil

Timelimit: 1

A parkour practitioner intends to make a video with several maneuvers where he will jump between several buildings in an ever-increasing trajectory, that is, he will always jump from one building to another that has greater height.

Although dangerous is something that attracts attention in sport, this sportsman does not intend to take any more risks than necessary.He intends to make his way from the building he chooses to start to the largest building he can ever jump to the nearest option on the left or right.

In other words, since Hi is the height of i-th building from the beginning of the street, he can jump from building i to building j if Hi < Hj and there is no building k such that Hi < Hk and i < k < j or j < k < i.

Your task is to determine how many different paths there are to make this video.

The description of the street where it will be filmed, the height of each building and its distance from the beginning of the street will be provided.

The traceur (person who practices parkour) can start in any of the buildings.

Input

The first line of input consists of a integer N (1 ≤ N ≤ 106), the number os buildings in the street.

The following N lines each consists of two integers: H (1 ≤ H ≤ 109) and X (1 ≤ X ≤ 109), that indicate the height of a building and its distance from the beginning of the street, respectively.

Output

The output must be a single line containing the number of ways to trace the path to the parkour video. Because this number can be very large, print only your module 109+7.
Input Samples Output Samples

4
31 30
63 10
127 130
15 70

7

6
17 6
35 9
30 1
19 3
18 8
20 4

15

9
3 1
5 2
1 3
6 4
3 5
4 6
7 7
2 8
4 9

14