402917: GYM100947 E Qwerty78 Trip

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Qwerty78 Triptime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

Qwerty78 is a well known programmer (He is a member of the ICPC WF winning team in 2015, a topcoder target and one of codeforces top 10).

He wants to go to Dreamoon's house to apologize to him, after he ruined his plans in winning a Div2 contest (He participated using the handle "sorry_Dreamoon") so he came first and Dreamoon came second.

Their houses are presented on a grid of N rows and M columns. Qwerty78 house is at the cell (1, 1) and Dreamoon's house is at the cell (N, M).

If Qwerty78 is standing on a cell (r, c) he can go to the cell (r + 1, c) or to the cell (r, c + 1). Unfortunately Dreamoon expected Qwerty78 visit , so he put exactly 1 obstacle in this grid (neither in his house nor in Qwerty78's house) to challenge Qwerty78. Qwerty78 can't enter a cell which contains an obstacle.

Dreamoon sent Qwerty78 a message "In how many ways can you reach my house?". Your task is to help Qwerty78 and count the number of ways he can reach Dreamoon's house. Since the answer is too large , you are asked to calculate it modulo 109 + 7 .

Input

The first line containts a single integer T , the number of testcases.

Then T testcases are given as follows :

The first line of each testcase contains two space-separated N , M ( 2 ≤ N, M ≤ 105)

The second line of each testcase contains 2 space-separated integers OR, OC - the coordinates of the blocked cell (1 ≤ OR ≤ N) (1 ≤ OC ≤ M).

Output

Output T lines , The answer for each testcase which is the number of ways Qwerty78 can reach Dreamoon's house modulo 109 + 7.

ExamplesInput
1
2 3
1 2
Output
1
Note

Sample testcase Explanation :

The grid has the following form:

Q*.

..D

Only one valid path:

(1,1) to (2,1) to (2,2) to (2,3).

加入题单

算法标签: