A. Fold Distance
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Thomas has been learning origami lately and is experimenting with grid-based folding patterns. To get started, he has made creases in a rectangular piece of paper to split it up into an $$$m \times n$$$ grid. Thomas has marked two of the grid cells and wants to know the minimum number of creases he has to fold along in order to get one of the marked cells to lie directly on top of the other.

Input

Each test consists of multiple test cases.

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases.

The first line of each test case contains two integers, $$$m$$$ and $$$n$$$ ($$$1 \le m, n \le 1000$$$) — the number of rows and columns of the grid, respectively.

The next line of each test case contains four integers, $$$r_1$$$, $$$c_1$$$, $$$r_2$$$, and $$$c_2$$$ ($$$1 \le r_1, r_2 \le m$$$ and $$$1 \le c_1, c_2 \le n$$$) — the coordinates of the first and second marked cells, respectively, where $$$(1, 1)$$$ is the top left cell and $$$(n, m)$$$ is the bottom right cell. It is guaranteed that the two marked cells are different.

Output

For each test case, output a single integer — the minimum number of crease folds required to land one of the marked cells on top of the other.

Example
Input
2
4 5
1 2 4 3
3 3
1 1 2 3
Output
2
3
Note

The first test case corresponds to the image above. Note that Thomas can only fold along the existing crease lines.

In the second test case, it can be proven that Thomas must make at least 3 folds.