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 si to ti (si < ti), 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 si to ti - 1 inclusive, but he can get off the i-th bus only on the bus stop ti.

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 (109 + 7).

Input

The first line contains two space-separated integers: n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 105). Then follow m lines each containing two integers si, ti. They are the numbers of starting stops and end stops of the buses (0 ≤ si < ti ≤ n).

Output

Print the only number — the number of ways to get to the school modulo 1000000007 (109 + 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 24 = 16.
import java.io.BufferedReader;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class A50 {

	static boolean test = false;

	private void solve() throws Throwable, IOException {
		int mod = 1000000007;
		
		int len = iread(), n = iread();
		Event[] events = new Event[2*n];
		
		for (int i = 0; i < n; i++) {
			int s = iread(), t = iread();
			events[i*2] = new Event(s,i,1);
			events[i*2 + 1] = new Event(t,i,-1);
		}
		
		Arrays.sort(events);
		if(n == 0 || events[0].x != 0 || events[events.length -1].x != len){
			out.write("0\n");
			return;
		}
		
		long[] y = new long[n];
		long cur = 1;
		long bonus = 0;
		
		for (int i = 0; i < 2 * n ; i++) {
			Event e = events[i];
			if(i == 0 || e.x != events[i - 1].x){
				cur = (cur + bonus) % mod;
				bonus = 0;
			}
			
			if(e.type == 1 ){
				if(e.x != 0){
					y[e.num] =  cur;
				}
			} else {
				bonus = (bonus + cur + mod - y[e.num]) % mod;
			}
		}
		out.write(bonus + "\n");
	}
	
	class Event implements Comparable<Event>{
		int x;
		int num;
		int type;
		
		public Event(int x, int num, int type) {
			super();
			this.x = x;
			this.num = num;
			this.type = type;
		}
		
		@Override
		public int compareTo(Event o) {
			if(x != o.x){
				return x - o.x;
			}
			return o.type - type;
		}
		
	}
//
//	public String str() throws IOException {
//		return in.readLine();
//	}
//
//	private int in() throws NumberFormatException, IOException {
//		return Integer.valueOf(str());
//	}
//
//	private long lon() throws NumberFormatException, IOException {
//		return Long.valueOf(str());
//	}
//
//	private int[] ints() throws Throwable {
//		StringTokenizer st = new StringTokenizer(str());
//
//		int[] res = new int[st.countTokens()];
//		for (int i = 0; i < res.length; i++) {
//			res[i] = Integer.parseInt(st.nextToken());
//		}
//		return res;
//	}
//
//	private long[] longs() throws Throwable {
//		StringTokenizer st = new StringTokenizer(str());
//
//		long[] res = new long[st.countTokens()];
//		for (int i = 0; i < res.length; i++) {
//			res[i] = Long.parseLong(st.nextToken());
//		}
//		return res;
//	}
//
//	private BigInteger[] bigs() throws Throwable {
//		StringTokenizer st = new StringTokenizer(str());
//
//		BigInteger[] res = new BigInteger[st.countTokens()];
//		for (int i = 0; i < res.length; i++) {
//			res[i] = new BigInteger(st.nextToken());
//		}
//		return res;
//	}

	public int iread() throws Exception {
		return Integer.parseInt(wread());
	}

	public double dread() throws Exception {
		return Double.parseDouble(wread());
	}

	public long lread() throws Exception {
		return Long.parseLong(wread());
	}

	public String wread() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) throws Throwable {
		new A50().solve();
		out.close();
	}

	public A50() throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File(testDataFile)));
		} else {
			new BufferedReader(inp);
		}
	}

	static InputStreamReader inp = new InputStreamReader(System.in);
	static BufferedReader in = new BufferedReader(inp);
	static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

	static String testDataFile = "testdata.txt";
	BufferedReader reader = null;
}