#Lutece2968. 不完全括号匹配
不完全括号匹配
Migrated from Lutece 2968 不完全括号匹配
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
一般的括号序列要求左括号的数目和右括号的数目相等。但是,如果左括号的数目大于等于右括号的数目,那么会有多少种括号序列,使得对于每一个右括号,都有一个左括号和它匹配呢? 答案对取模。
Input
第一行一个整数,表示数据组数。 接下来行,每行两个整数,,表示有个左括号,个右括号。
Output
对于每一组询问输出一个整数,表示答案对取模后的结果。
Samples
2
1 1
3 2
1
5
Constraints
$1\leq m \leq n \leq 5 \times 10^5,1<n+m\leq 5 \times 10^5$
Note
对于样例二,可能的五种情况分别为
Resources
2023 UESTC ICPC Training for Math