Number Puzzle

No attempts yetTime limit5sMemory limit128 MB

Statement

A number puzzle asks you to connect equal marked numbers on a grid with a single unbroken line. In this problem the grid has the digit 11 written in exactly two distinct cells, and you must decide whether a line satisfying all of the following rules can be drawn.

  • The line is a single unbroken path; it never branches and never crosses itself.
  • The line passes through every cell of the grid exactly once.
  • The two cells holding 11 are the two endpoints of the line.

Equivalently, treat every cell as a vertex and join two cells that are adjacent up, down, left, or right. The question is whether a path that starts at one 11, ends at the other, and visits every cell exactly once exists.

The grid has size m×nm \times n, where both mm and nn are even.

Input

The first line contains the number of test cases TT.

Each test case consists of three lines. The first line contains the number of rows mm and the number of columns nn, separated by a space (2m,n1002 \le m, n \le 100; both mm and nn are even). The second line gives the position of the first 11 as a row ii and a column jj, and the third line gives the position of the second 11 as a row aa and a column bb (1i,am1 \le i, a \le m, 1j,bn1 \le j, b \le n). The two positions are different.

Output

For each test case, print 11 if such a line can be drawn, or 1-1 if it cannot, on its own line.