#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 A×BA \times B. To simplify placement, she compressed the toys into rectangles, with sizes a1×b1a_1 \times b_1 and a2×b2a_2 \times b_2, 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 998244353998244353.

Input Format

The first line contains an integer TT, representing the number of test cases.

The following TT lines each contain 6 positive integers: A,B,a1,b1,a2,b2A, B, a_1, b_1, a_2, b_2, 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 998244353998244353.

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: A,B109A, B \leq 10^9, a1,a2,b1,b2108a_1, a_2, b_1, b_2 \leq 10^8, T105T \leq 10^5.