Vishal and Numbers..!

0

0 votes
Recruit, Hiring, Easy-Medium, Modular exponentiation, Mathematics, Approved
Problem

Vishal and Priyanka are friends. Priyanka has been given a task by her teacher. Since Vishal likes Priyanka, help him in impressing her.

The task is that there are NxM dots in a screen pattern lock. There are some rules for all the possible lock patterns. The lock pattern starts at the coordinates: (X1,Y1) and ends at (X2,Y2). From any dot, the pattern can only move in these directions: right, left or bottom. Also, the pattern never repeats over same dot.

Given (X1,Y1) and (X2,Y2), find out how many different patterns can exist. Since answer may be very large, output your answer modulo (109+7).

Input Format:
The first line has an integer T which represents number of test cases.
Each test case has two lines. The first line of test case has two integers N,M.
The second line has four integers X1,Y1,X2,Y2.

Output Format:
Print answer for each test case modulo (109+7).

Input Constraints:
1T1000000
1N,M108
1X1,Y1,X2,Y2108

Note:
(X1,Y1) != (X2,Y2)
X2X1

Sample Input
2
2 2
1 1 2 2
2 2
1 2 2 1
Sample Output
2
2
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?