human
A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of n rows and m columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the r-th row and the c-th column is denoted as (r,c). The initial position of the robot is (r_b, c_b).

In one second, the robot moves by dr rows and dc columns, that is, after one second, the robot moves from the cell (r, c) to (r + dr, c + dc). Initially dr = 1, dc = 1. If there is a vertical wall (the left or the right walls) in the movement direction, dc is reflected before the movement, so the new value of dc is -dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so the new value of dr is -dr.

Each second (including the moment before the robot starts moving), the robot cleans every cell lying in the same row or the same column as its position. There is only one dirty cell at (r_d, c_d). The job of the robot is to clean that dirty cell.

 Illustration for the first example. The blue arc is the robot. The red star is the target dirty cell. Each second the robot cleans a row and a column, denoted by yellow stripes.

Given the floor size n and m, the robot's initial position (r_b, c_b) and the dirty cell's position (r_d, c_d), find the time for the robot to do its job.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

A test case consists of only one line, containing six integers n, m, r_b, c_b, r_d, and c_d (1 ≤ n, m ≤ 100, 1 ≤ r_b, r_d ≤ n, 1 ≤ c_b, c_d ≤ m) — the sizes of the room, the initial position of the robot and the position of the dirt cell.

Output

For each test case, print an integer — the time for the robot to clean the dirty cell. We can show that the robot always cleans the dirty cell eventually.

Example

Input

5
10 10 6 1 2 8
10 10 9 9 1...
debug ... Give me a Python code to find the time for the robot to do its job?
assistant
#Here is Python code to find the time for the robot to do its job.
 = False

if debug:
    s = """5
    10 10 6 1 2 8
    10 10 9 9 1 1
    9 8 5 6 2 1
    6 9 2 2 5 8
    2 2 1 1 2 1"""
    input_data = iter(s.split('\n'))
else:
    def func():
        while 1:
            yield input()

    input_data = func()

def get_data():
    n_data = int(next(input_data))
    for _ in range(n_data):
        n, m, cleaner_row, cleaner_column, mud_row, mud_column = map(int, next(input_data).split())
        yield n, m, cleaner_row, cleaner_column, mud_row, mud_column

def solve(n, m, cleaner_row, cleaner_column, mud_row, mud_column, dr=1, dc=1):
    steps = 0
    while cleaner_row != mud_row and cleaner_column != mud_column:
        if not (0 < cleaner_row + dr <= n):
            dr = -dr
        if not (0 < cleaner_column + dc <= m):
            dc = -dc
        cleaner_row = cleaner_row + dr
        cleaner_column = cleaner_column + dc
        steps += 1
    print(steps)

def main():
    for data in get_data():
        solve(*data)

if __name__ == '__main__':
    main()