#SL2310G. Make 2

Make 2

Make 2

For a sequence aa consisting of nn positive integers, you can perform the following operation several times:

  • Choose an index ii which satisfies 1<i<n1 < i < n and ai>1a_i > 1, then decrease aia_i by 11, and add 11 to ai1a_{i−1} and ai+1a_{i+1}.

A sequence consisting of nn positive integers is considered good if it is possible to make ai=2a_i = 2 for each 1in1 \leq i \leq n, by using several (possibly, zero) such operations.

Now you need to calculate the number of good sequences that satisfy mm constraints, the ii-th constraint can be represented as a pair (xi,yi)(x_i,y_i) which requires axi=yia_{x_i} = y_i.

It can be proven that the answer is finite. Output the answer modulo 109+710^9 +7.

Input

The first line contains a single integer T(1T10)T \: (1 \leq T \leq 10), denoting the number of test cases.

For each test case, the first line contains two integers $n,m \: (1 \leq n \leq 10^{18}, 0 \leq m \leq min(n,100))$.

The next mm lines each contains two integers. The ii-th line contains $x_i,y_i \: (1 ≤ x_1 < x_2 < \dots < x_m \leq n, 1 \leq y_i \leq10^9)$.

Output

For each test case, output one line with an integer denoting the answer modulo 109+710^9 +7.

Example

3
3 1
2 2
5 2
1 2
5 1
114514 0
1
2
158552999