Bârlad is the home of some rocky landscapes and very bad drivers. The train passed Bârlad way too fast for Little IR12660 to actually visit it. So now he can only imagine what Bârlad might look like. He knows Bârlad is a city stretching along a single line, and he also knows that if the landscape across this line gets too complicated for the locals, they might crash. So, he formulates the following problem:
Count the number of permutations of order $$$N$$$ that satisfy $$$M$$$ restrictions of the following types:
An array is considered:
A strictly increasing or strictly decreasing array is considered neither a valley nor a mountain.
The first line contains a single integer $$$t$$$ ($$$1 \leq T \leq 500$$$) — the number of test cases.
The description of each test case is as follows:
It is guaranteed that the sum of $$$N$$$ across all test cases does not exceed $$$2\,000$$$ and the sum of $$$M$$$ across all test cases does not exceed $$$2\,000$$$.
For each test case, output a single integer — the number of permutations of size $$$n$$$ that satisfy all $$$m$$$ restrictions modulo $$$10^9 + 7$$$.
55 21 3 12 5 24 11 4 16 31 4 22 5 13 6 23 21 3 11 3 25 0
20 6 0 0 120
| Name |
|---|


