After winning every chess tournament on a 100 km radius around Râmnicu-Vâlcea, Bogdan realized his only real opponent is himself. He decided to quit chess and invent his own wooden piece-placing game. He starts with a square board of side and L-shaped pieces. The two "arms" of the piece are of equal length, and all pieces have different lengths between and .
The rows of the board, as well as its columns, are numbered from to . A position on the board is identified by two numbers and , representing the row and the column of that position, respectively. The top left corner of the board is denoted .

Bogdan wants to find out how many different ways he can arrange the pieces on the board. To make the problem more interesting he decided to impose restrictions. A restriction consists of 3 integers , meaning that the corner of the piece with side length must be placed in the position . Notice that the piece can be in any orientation as long as its corner is in the correct position.
Task
Given the size of a board and restrictions, find how many ways you can complete the board, modulo , satisfying the restrictions.
Input data
The first line of the input contains the integer , the number of games you'll play. \
Each game is given in the following way:
- the first line contains the integer , the length of the board's side;
- the second line contains the integer , the number of imposed restrictions;
- the next lines contain each integers , with the meaning specified in the statement.
Output data
The output will consist of lines, the -th line () containing the result for the -th game.
Constraints and clarifications
- A piece of any given size will have at most one restriction during a game.
- It is guaranteed that there exists at least one way to complete the board.
- The sum of over all test cases doesn't exceed .
| # | Score | Constraints |
|---|---|---|
| 0 | 0 | Examples |
| 1 | 6 | |
| 2 | 9 | |
| 3 | 16 | (one restriction imposed, for a piece with the side of length placed at the top of the board) |
| 4 | 23 | (one restriction imposed, for a piece with side length ) |
| 5 | 17 | |
| 6 | 29 | No further restrictions. |
Example 1
stdin
3
6
2
1 6 5
4 3 2
2
0
3
1
2 2 2
stdout
2
4
4
Explanation
For the first game there are 2 ways to fill the board:

The second game doesn't have any restrictions, there are 4 ways to complete it.
The third game can be completed in 4 ways:

Example 2
stdin
1
40
1
7 20 20
stdout
202092513