#P1924D. Balanced Subsequences
Balanced Subsequences
No submission language available for this problem.
Description
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.
A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
You are given three integers , and . Find the number of sequences consisting of '(' and ')', such that the longest balanced subsequence is of length . Since the answer can be large calculate it modulo ().
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains three integers , and ()
For each test case, print one integer — the answer to the problem.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains three integers , and ()
Output
For each test case, print one integer — the answer to the problem.
Note
For the first test case "()()", "(())" are the sequences
For the second test case no sequence is possible.
For the third test case ")((()", ")(()(", ")()((", "())((" are the sequences.