Problem: You are given an integer and intervals. The -th interval is where .
Let us call a regular bracket sequence of length hyperregular if for each such that , the substring is also a regular bracket sequence.
Your task is to count the number of hyperregular bracket sequences. Since this number can be really large, you are only required to find it modulo .
A bracket sequence is a string containing only the characters "(" and ")".
A bracket sequence is called regular if one can turn it into a valid math expression by adding characters + and 1. For example, sequences (())(), (), (()(())) and the empty string are regular, while )(, ((), and (()))( are not.
Input Format: Each test contains multiple test cases. The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers and (, ) — the length of the hyperregular bracket sequences and the number of intervals respectively.
The following lines of each test case contains two integers and ().
It is guaranteed that the sum of across all test cases does not exceed and the sum of across all test cases does not exceed .
Output Format: For each test case, output the number of hyperregular bracket sequences modulo .
Note:
- For the first testcase, the hyperregular bracket strings of length are: ((())), (()()), (())(), ()(()) and ()()().
- For the second testcase, there are no regular bracket strings of length , and consequently, there are no hyperregular bracket strings of length .
- For the third testcase, there are no hyperregular bracket strings of length for which the substring is a regular bracket string.
- For the fourth testcase, there hyperregular bracket strings are: ((())(())), ((())()()), ()()((())) and ()()(()())