P22356 [HackerRank] Merge list
普及
题目描述

Shashank is very excited after learning about the linked list. He learned about how to merge two linked lists. When we merge two linked lists, the order of the elements of each list doesn't change. For example, if we merge $[1,2,3]$ and $[4,5,6]$, $[1,4,2,3,5,6]$ is a valid merge, while $[1,4,3,2,5,6]$ is not a valid merge because $3$ appears before $2$.

Shashank wants you to solve a problem for him: You are given two lists having sizes $N$ and $\mbox{M}$. How many ways can we merge both the lists? It is given that all $N+M$ elements are distinct. As your answer can be quite large, Shashank wants you to print it $\:\textbf{mod}\:10^9+7$.

Input Format

The first line contains an integer $\mathbf{T}$, the number of test cases.

Each of the next $\mathbf{T}$ lines contains two integers $N$ and $\mbox{M}$.

Constraints

$1\leq T\leq10$
$1\leq N\leq100$
$1\leq M\leq100$

Output Format

Print the value of the answer $\:\textbf{mod}\:10^9+7$.

Sample Input 0
1
2 2

Sample Output 0
6

Explanation 0

Suppose the two lists are $[1,2]$ and $[3,4]$. The different ways of merging these lists are given below:

$[1,2,3,4]$

$[1,3,2,4]$

$[3,4,1,2]$

$[3,1,4,2]$

$[1,3,4,2]$

$[3,1,2,4]$

输入格式

见题面

输出格式

见题面

样例输入
1 2 2
样例输出
6