402796: GYM100883 G Count Mix Strings

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Count Mix Stringstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

While I was working in the company, the internet broke. I didn't have anything to do without internet, so I decided to write this ACM problem.

We need to mix between two strings and also we should keep the same order for both strings.

example: if we have s1 = "ab" and s2 = "cd", we can generate six strings:

abcd acbd

acdb cdab

cadb cabd

but now I have a problem. I need to calculate the complexity for this problem to make input and output files.

you will be given the length of two strings and you should help me to find the number of strings that could be generated (if there is a repeated string, count it every time).

Input

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 10000). Followed by the test cases, each test case is on one line. it contains two numbers N and M the length of s1 and s2 where 1 ≤ N, M ≤ 10000

Output

For each test case, print a single line which contains a single integer that is representing the number of strings that could be generated MOD 10^9+7.

ExamplesInput
3
1 1
1 2
2 2
Output
2
3
6

加入题单

上一题 下一题 算法标签: