Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Buses

time limit per test

2 secondsmemory limit per test

265 megabytesinput

standard inputoutput

standard outputLittle boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly *n* + 1 bus stops. All of them are numbered with integers from 0 to *n* in the order in which they follow from Gerald's home. The bus stop by Gerald's home has number 0 and the bus stop by the school has number *n*.

There are *m* buses running between the house and the school: the *i*-th bus goes from stop *s*_{i} to *t*_{i} (*s*_{i} < *t*_{i}), visiting all the intermediate stops in the order in which they follow on the segment. Besides, Gerald's no idiot and he wouldn't get off the bus until it is still possible to ride on it closer to the school (obviously, getting off would be completely pointless). In other words, Gerald can get on the *i*-th bus on any stop numbered from *s*_{i} to *t*_{i} - 1 inclusive, but he can get off the *i*-th bus only on the bus stop *t*_{i}.

Gerald can't walk between the bus stops and he also can't move in the direction from the school to the house.

Gerald wants to know how many ways he has to get from home to school. Tell him this number. Two ways are considered different if Gerald crosses some segment between the stops on different buses. As the number of ways can be too much, find the remainder of a division of this number by 1000000007 (10^{9} + 7).

Input

The first line contains two space-separated integers: *n* and *m* (1 ≤ *n* ≤ 10^{9}, 0 ≤ *m* ≤ 10^{5}). Then follow *m* lines each containing two integers *s*_{i}, *t*_{i}. They are the numbers of starting stops and end stops of the buses (0 ≤ *s*_{i} < *t*_{i} ≤ *n*).

Output

Print the only number — the number of ways to get to the school modulo 1000000007 (10^{9} + 7).

Examples

Input

2 2

0 1

1 2

Output

1

Input

3 2

0 1

1 2

Output

0

Input

5 5

0 1

0 2

0 3

0 4

0 5

Output

16

Note

The first test has the only variant to get to school: first on bus number one to the bus stop number one; then on bus number two to the bus stop number two.

In the second test no bus goes to the third bus stop, where the school is positioned. Thus, the correct answer is 0.

In the third test Gerald can either get or not on any of the first four buses to get closer to the school. Thus, the correct answer is 2^{4} = 16.

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/12/2021 04:37:40 (g1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|