Number of paths

0

0 votes
Problem

Jaggi and Jojo are interested in problems related with Grids. They were trying different problem on grids, when they found this one. Given a grid of size NXN. Its bottom-left point is (0,0) and top-right element is (N-1,N-1).

We can traverse the grid in either top or right direction. You have to find the number of ways to traverse from the bottom-left to top-right point. There are some checkpoints which you have to visit in every path. There is atleast one valid path.

Input

The input file consists of several cases T (1<=T<=5). The first line of each case contains a positive integer N (1<=N<=1000) specifying the size of grid and the number of checkpoints Q (0<=Q<=100).
In next line there are Q space separated co-ordinates (a,b) of the checkpoints. Checkpoints are 0-Indexed.

Output

For every testcase, you have to print the answer modulo 1000000007.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?