Codeforces Round 921 (Div. 1)
D
Balanced Subsequences
Codeforces
2700
原题
← CE →
翻译中…

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 $n$, $m$ and $k$. Find the number of sequences consisting of $n$ '(' and $m$ ')', such that the longest balanced subsequence is of length $2 \cdot k$. Since the answer can be large calculate it modulo $1\,000\,000\,007$ ($10^9 + 7$).

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 3 \cdot 10^3$). Description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $m$ and $k$ ($1 \le n, m, k \le 2 \cdot 10^3$)

翻译中…

Output

翻译中…

For each test case, print one integer — the answer to the problem.

翻译中…

Note

翻译中…

For the first test case "()()", "(())" are the $2$ sequences

翻译中…

For the second test case no sequence is possible.

翻译中…

For the third test case ")((()", ")(()(", ")()((", "())((" are the $4$ sequences.

翻译中…

样例

Input #1
3
2 2 2
3 2 3
3 2 1
Output #1
2
0
4
InputCopy OutputCopy
题目信息
题号
1924D
时间限制
1 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。