Chef feels that being the Head Chef is a very difficult job. More than cooking, managing the kitchen and distributing the work between various cooks proves to be a tiring task. There are many dishes to be prepared. And he has a team of talented cooks to do this for him. But the Chef always has a problem distributing tasks among them. For a cook i, the Chef wants to give him atleast xi dishes to prepare in a day. But different cooks have different capacities. Any cook i can cook atmost yi number of dishes in a single day. Chef is very aware of every cook's capability and will not give anyone more work than his maximum capacity. Now, he wants you to help him out here. 
Your task will be simple: Tell him the number of ways in which he can distribute the given number of dishes among his team.

------ Input: ------ 

First line contains T, number of tests.
Each test begins with a single line containing 2 space separated integers: n and m, the number of dishes to be prepared and the number of cooks in Chef's team.

Then follow m lines. The ith line contains 2 space separater integers which are the corresponding xi and yi.

------ Output: ------ 

For every test case, output a single integer: the number of ways of distributing the work mod 1000000007.

------ Constraints: ------ 

1≤T≤50

1≤n,m≤100

0≤xi,yi≤100

----- Sample Input 1 ------ 
1
3 2
0 3
1 3
----- Sample Output 1 ------ 
3
----- explanation 1 ------ 
Test case $1$: Chef can distribute the dishes in the following three ways:
- $0$ dishes for the first cook and $3$ dishes for the second cook.
- $1$ dish for the first cook and $2$ dishes for the second cook.
- $2$ dishes for the first cook and $1$ dish for the second cook.

Difficulty: MEDIUM

Solutions:
def generate_sums(array):
	cur_sum = 0
	sums = [0] * len(array)
	for i in range(len(array)):
		cur_sum += array[i]
		sums[i] = cur_sum
	return sums

def dishdis(foods, cooks):
	cook = cooks.pop()
	previous = [1 if cook[0] <= food_count <= cook[1] else 0 for food_count in range(foods + 1)]
	previous_sums = generate_sums(previous)
	while cooks:
		cook = cooks.pop()
		current = [0] * (foods + 1)
		for i in range(0, foods + 1):
			interval_start = max(-1, i - cook[1] - 1)
			interval_end = i - cook[0]
			if interval_end < 0:
				current[i] = 0
			elif interval_start < 0:
				current[i] = previous_sums[interval_end]
			else:
				current[i] = previous_sums[interval_end] - previous_sums[interval_start]
		previous = current
		previous_sums = generate_sums(previous)
	return previous[foods] % 1000000007
for _ in range(int(input())):
	(foods, cook_count) = [int(x) for x in input().split()]
	cooks = [[int(x) for x in input().split()] for _ in range(cook_count)]
	print(dishdis(foods, cooks))