Count Paths

0

0 votes
Easy
Problem

There is a grid of dimension n×m. Khatru is at the point (1,1) and he needs to go to the point (n,m) in the grid. The only constraint is that he needs to pass through the point (x,y). He can only move towards right or down.

Help him by finding the number of ways, he can do so. As the answer can be large, output it % 1000000007.

Input

The first line contains an integer q denoting the total number of queries.

Each of the next q lines contains 4 integers x, y, n, m.

Output

For each test case, print an integer denoting the total number of ways to reach the point (n,m).

Constraints

1q105

1xn

1ym

Subtask 1: 20 Points

1n103

1m103

Subtask 2: 80 Points

1n106

1m106

Sample Input
4
2 2 2 3
5 1 5 1
3 1 5 1
4 2 5 3
Sample Output
2
1
1
8
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?