Huge Knight

No attempts yetTime limit1sMemory limit128 MB

Problem

You have a chessboard of size N×NN \times N. The rows and the columns are numbered from 1 to NN. A knight starts on the cell in row R1R_1, column C1C_1, and it wants to reach the cell in row R2R_2, column C2C_2.

One knight move goes two cells along one axis and one cell along the other. A knight on (A,B)(A, B) can move to (A2,B1)(A-2, B-1), (A2,B+1)(A-2, B+1), (A+2,B1)(A+2, B-1), (A+2,B+1)(A+2, B+1), (A1,B2)(A-1, B-2), (A+1,B2)(A+1, B-2), (A1,B+2)(A-1, B+2), or (A+1,B+2)(A+1, B+2). The knight cannot leave the board.

Given NN, R1R_1, C1C_1, R2R_2, and C2C_2, find the minimum number of moves that takes the knight from (R1,C1)(R_1, C_1) to (R2,C2)(R_2, C_2).

Input

The first line contains a positive integer TT, the number of test cases.

Each test case is one line with five integers NN, R1R_1, C1C_1, R2R_2, C2C_2. Here 3N10153 \le N \le 10^{15}, and R1R_1, C1C_1, R2R_2, C2C_2 are between 1 and NN inclusive.

Output

For each test case, print the minimum number of moves that takes the knight from (R1,C1)(R_1, C_1) to (R2,C2)(R_2, C_2), one per line.

Assume a solution always exists, so every input gives a destination the knight can reach from its starting cell.