Little 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*<sub class="lower-index">*i*</sub> to *t*<sub class="lower-index">*i*</sub> (*s*<sub class="lower-index">*i*</sub> &lt; *t*<sub class="lower-index">*i*</sub>), 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*<sub class="lower-index">*i*</sub> to *t*<sub class="lower-index">*i*</sub> - 1 inclusive, but he can get off the *i*-th bus only on the bus stop *t*<sub class="lower-index">*i*</sub>.

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<sup class="upper-index">9</sup> + 7).
The first line contains two space-separated integers: *n* and *m* (1 ≤ *n* ≤ 10<sup class="upper-index">9</sup>, 0 ≤ *m* ≤ 10<sup class="upper-index">5</sup>). Then follow *m* lines each containing two integers *s*<sub class="lower-index">*i*</sub>, *t*<sub class="lower-index">*i*</sub>. They are the numbers of starting stops and end stops of the buses (0 ≤ *s*<sub class="lower-index">*i*</sub> &lt; *t*<sub class="lower-index">*i*</sub> ≤ *n*).
2 2
0 1
1 2
1
3 2
0 1
1 2
0
5 5
0 1
0 2
0 3
0 4
0 5
16
3 3
1 2
2 3
1 3
0
10 10
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
512
6 6
3 4
2 3
3 5
0 1
1 2
3 6
4
7 7
0 1
1 3
2 3
4 6
5 7
4 5
5 7
0
1000000000 0
0
8 8
0 1
4 5
7 8
3 4
2 3
6 7
5 6
1 2
1
6 1
0 6
1
6 4
0 3
1 2
4 5
4 6
0
5 15
0 1
0 2
0 3
0 4
0 5
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
360
5 3
0 1
2 3
4 5
0
5 15
0 1
1 2
2 3
3 4
4 5
1 2
2 3
3 4
4 5
2 3
3 4
4 5
3 4
4 5
4 5
120
8 94
2 8
3 8
5 6
1 2
4 6
2 7
2 4
3 5
0 2
0 1
7 8
0 7
0 5
1 4
2 7
3 4
6 7
1 5
4 6
4 6
2 8
4 5
0 1
3 8
5 8
1 3
3 4
1 6
1 6
1 7
1 7
1 4
5 6
5 7
2 4
3 8
0 1
0 4
4 8
1 8
3 8
2 4
5 7
2 4
2 7
3 8
3 7
0 6
1 2
0 2
2 7
0 4
0 3
3 6
0 2
5 7
4 8
3 6
0 3
3 5
2 3
1 8
3 7
0 6
4 6
1 8
1 2
3 5
1 5
1 2
0 2
0 3
4 7
1 4
2 5
5 8
0 3
5 7
5 8
0 2
1 5
4 6
3 6
5 6
0 6
1 7
7 8
2 7
2 4
1 7
0 7
1 6
3 8
0 7
203624961
97 53
21 34
19 95
0 6
28 40
26 41
39 41
47 85
32 46
2 17
55 73
18 67
36 85
77 96
77 97
1 53
12 49
9 71
29 92
35 89
40 43
5 78
13 92
2 97
11 22
4 6
22 92
60 87
25 47
10 59
51 70
13 95
27 43
5 71
48 73
82 94
45 51
85 97
51 89
15 66
44 80
78 93
65 84
9 75
28 30
39 69
50 89
41 77
14 31
12 97
69 86
15 18
14 56
38 47
478604297
33 5
17 18
5 27
18 29
12 24
14 31
0
93 69
9 92
31 37
58 83
28 93
36 44
22 90
61 88
76 83
19 85
25 87
55 84
45 47
5 27
54 82
4 65
12 81
49 55
16 52
16 34
34 44
17 36
62 64
7 34
19 21
16 73
3 55
12 62
49 91
2 36
47 65
17 37
70 80
52 71
59 77
1 17
23 81
15 67
38 67
14 48
70 82
33 51
31 88
28 51
10 54
6 71
37 88
5 60
2 91
88 91
30 91
17 58
12 72
14 77
34 90
15 42
44 47
54 87
84 90
3 49
26 71
40 87
71 74
20 60
86 92
76 83
40 80
3 31
18 33
5 82
0
10 59
4 7
4 8
0 4
5 7
6 9
7 8
0 9
6 7
4 9
1 10
5 6
1 4
0 4
4 9
3 6
1 7
4 9
3 7
1 2
0 1
4 7
0 8
8 10
0 3
2 5
0 7
1 8
2 10
0 3
0 9
7 8
2 6
1 6
2 10
3 10
3 4
0 2
0 8
3 8
9 10
1 6
7 10
6 9
2 10
2 10
3 5
9 10
4 10
0 8
5 9
4 6
0 10
6 9
1 2
6 7
1 5
0 6
0 7
0 6
28167561
66 35
49 55
9 30
28 54
44 62
55 61
1 21
6 37
8 10
26 33
19 37
12 23
24 42
34 64
8 56
36 40
16 58
21 30
16 36
36 38
19 45
26 49
6 62
1 11
22 48
33 38
8 41
29 53
58 60
27 66
2 19
48 53
25 47
48 56
61 65
45 46
0
31 26
15 21
4 25
5 19
16 18
5 23
3 25
7 18
24 31
6 9
8 25
18 29
12 27
15 16
12 20
2 7
14 26
13 22
5 19
5 24
15 23
4 7
8 12
14 26
28 30
1 30
24 31
0
69 68
49 62
3 38
1 43
42 58
12 64
1 37
35 59
7 43
2 29
8 65
19 47
4 27
41 58
25 60
17 37
34 40
16 38
28 52
35 63
6 65
57 58
38 50
8 28
6 8
10 44
48 63
2 42
46 58
26 62
37 45
7 22
0 21
19 48
6 67
6 15
28 38
19 22
16 20
27 40
0 3
33 69
2 66
10 24
29 48
26 69
15 53
24 34
34 58
20 47
21 23
38 68
34 45
60 68
7 15
21 34
16 30
14 58
2 62
24 66
13 27
24 40
32 37
10 37
22 40
44 50
27 31
0 44
20 32
622740890
1 0
0
68 74
51 54
3 22
12 24
3 27
32 42
36 55
60 64
1 4
4 23
11 64
54 62
50 56
21 34
27 63
15 54
28 61
13 57
39 53
12 32
32 40
33 67
55 61
33 67
30 37
15 49
27 45
21 41
8 42
24 63
40 48
28 41
30 67
0 4
7 15
27 59
60 62
25 65
30 31
38 67
24 43
14 64
26 46
8 12
34 41
32 67
11 42
11 53
45 55
2 47
7 51
30 54
21 44
7 52
40 62
16 50
10 41
26 65
16 51
6 29
1 31
48 54
9 42
33 45
19 59
25 37
21 62
20 58
23 59
12 61
2 46
19 49
44 60
1 20
19 66
0
79 68
26 47
55 70
5 40
7 45
16 21
31 38
19 62
40 55
42 78
60 61
43 69
50 73
3 77
2 45
2 29
10 58
2 11
62 76
57 70
65 73
37 67
9 24
4 28
8 16
31 44
10 66
47 70
19 45
17 28
5 36
9 68
2 35
55 77
51 71
1 59
6 33
21 53
39 49
59 70
17 44
18 64
49 78
0 52
24 56
65 79
19 51
42 77
37 78
20 39
47 56
19 78
50 78
3 67
37 47
5 27
40 51
24 29
50 54
45 50
13 76
29 31
0 28
26 36
21 44
71 77
55 58
38 61
22 44
317376853
45 51
2 12
6 18
4 17
8 25
16 24
3 23
29 31
31 40
7 26
5 6
35 37
1 36
9 45
18 36
12 27
5 15
11 16
19 29
8 23
1 27
0 30
25 38
21 44
34 39
10 41
4 16
11 36
0 8
15 38
3 33
11 31
2 33
5 34
24 28
7 32
15 25
2 27
16 44
31 40
35 45
13 38
29 42
18 23
8 25
13 21
3 39
3 41
5 6
13 21
11 20
23 42
493168232
5 31
0 2
3 4
3 5
2 4
1 3
1 2
2 5
1 5
0 2
2 5
1 4
0 2
1 3
0 5
2 3
1 5
1 2
2 3
0 1
0 1
2 4
0 4
1 2
0 3
1 2
3 4
0 2
0 4
1 2
2 5
1 5
8595
81 52
33 48
59 61
37 77
58 73
29 54
1 17
8 29
50 73
7 26
35 41
22 26
9 22
0 11
40 73
25 57
35 55
36 54
29 41
56 66
42 77
29 48
41 66
25 36
2 55
58 64
0 61
23 31
9 61
27 45
2 71
14 29
4 31
0 35
31 77
21 39
0 54
46 68
18 62
41 45
12 28
59 66
39 71
10 59
29 77
16 48
13 46
30 73
2 41
42 55
19 61
28 29
20 42
0
84 50
33 46
19 40
51 64
37 45
35 81
44 81
6 57
57 60
14 53
15 49
4 30
35 49
2 51
8 72
15 18
49 51
14 49
50 71
41 59
28 60
61 81
9 12
34 79
5 56
60 67
21 60
39 71
31 60
13 35
16 84
17 33
48 57
36 61
50 55
5 84
66 79
61 70
42 49
19 39
47 49
3 82
59 65
8 44
71 80
66 77
8 65
1 81
7 82
50 74
10 17
0
100 68
77 89
19 71
11 46
23 70
16 47
4 61
7 96
38 74
79 95
68 75
14 86
10 55
7 13
88 99
19 21
4 94
17 83
11 16
7 50
58 96
4 58
17 72
44 56
35 91
50 88
9 37
36 52
83 89
8 16
1 80
12 75
3 27
92 93
53 88
37 49
34 78
31 66
39 55
36 94
22 67
47 85
20 58
62 98
41 89
85 96
11 73
39 95
44 68
25 33
36 45
66 70
66 93
17 97
1 71
49 53
47 54
19 95
10 12
38 57
47 68
21 70
32 93
53 71
45 59
27 48
47 63
75 76
8 57
0
918949684 6
351553415 785588657
423490842 845475457
351553415 918949684
740298829 785588657
351328841 610486484
423490842 847590951
0
863261873 5
137690029 666186924
137690029 379800754
515537329 666186924
442925959 722302912
137690029 863261873
0
735324925 2
642054038 735324925
170935185 642054038
0
977743286 6
317778866 395496218
395496218 932112884
98371691 432544933
440553 922085291
440553 432544933
586988624 922085291
0
977700285 7
386643627 467079072
116215943 914856211
15183537 386643627
424146511 977700285
15183537 620050423
336304090 947990602
116215943 914856211
0
768016717 4
242598247 348534209
33560125 170667468
348534209 700314158
700314158 768016717
0
814609521 3
622460875 697824636
283825432 369448402
614658965 622460875
0
931612300 8
64655010 186892167
25283092 580196656
297609123 628681221
25283092 186892167
186892167 221075230
221075230 634105512
25283092 156293949
86333513 156293949
0
947714605 4
23890708 35992029
35992029 947714605
93644635 629491402
23890708 947714605
0
768016717 4
242598247 348534209
33560125 170667468
348534209 700314158
700314158 768016717
0
1000000000 2
0 500000000
500000000 1000000000
1
# ﷽
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque
import sys
input = lambda: sys.stdin.readline().strip()

def solve():
    n,m=[int(i) for i in input().split()]
    d=defaultdict(list)
    for _ in range(m):
        u,v=[int(i) for i in input().split()]
        d[v].append(u)

    b=[0]+sorted(set(d.keys()))
    
    dp=[0,1]
    sumdp=[0,1]
    for i in range(1,len(b)):
        tmp=0
        for v in d[b[i]]:
            j=bisect_left(b,v)
            tmp+=sumdp[-1]-sumdp[j]
        dp.append(tmp)
        sumdp.append(tmp+sumdp[-1])
    if b[-1]!=n:print(0);return
    print(dp[-1])
    # print(dp)
             
    

if __name__ == "__main__":
    # for i in range(int(input())):
        solve()


