#4. 若成为星座
若成为星座
Problem Statement
Little Atom has two adorable toys that she wants to put into a toy storage box. The storage box is a rectangular grid of size . To simplify placement, she compressed the toys into rectangles, with sizes and , respectively. The requirement is that the top-left corner of each toy must be placed on an integer grid point of the storage box, and the two toys cannot overlap (note: the boundaries can touch, but there must be no overlapping area, i.e., the shared area must be zero).
Little Atom wants to know how many distinct ways there are to place both toys in the storage box. The result must be taken modulo .
Input Format
The first line contains an integer , representing the number of test cases.
The following lines each contain 6 positive integers: , which represent the size of the storage box and the sizes of the two toys, respectively.
Output Format
For each test case, output a single positive integer, representing the number of ways to place the two toys, modulo .
Sample #1
Sample Input #1
3
2 2 1 1 1 1
3 3 2 2 1 1
5 5 3 3 2 4
Sample Output #1
12
20
12
Constraints
- Data range: , , .
相关
在下列比赛中: