Problem: Conveyor matrix is matrix of size , where is an even number. The matrix consists of concentric ribbons moving clockwise.
In other words, the conveyor matrix for is simply a matrix , whose cells form a cycle of length clockwise. For any natural , the matrix is obtained by adding to the matrix an outer layer forming a clockwise cycle.
The conveyor matrix .
You are standing in a cell with coordinates and you want to get into a cell with coordinates . A cell has coordinates if it is located at the intersection of the th row and the th column.
Standing on some cell, every second you will move to the cell next in the direction of movement of the tape on which you are. You can also move to a neighboring cell by spending one unit of energy. Movements happen instantly and you can make an unlimited number of them at any time.
Your task is to find the minimum amount of energy that will have to be spent to get from the cell with coordinates to the cell with coordinates .
For example, initially you are in a cell with coordinates and you want to get into a cell with coordinates . You can immediately make movements, once you are in a cell with coordinates , and then after seconds you will be in the right cell.
Input Format: The first line contains an integer () — the number of test cases.
The descriptions of the test cases follow.
The description of each test case consists of one string containing five integers , , , and () — matrix size and the coordinates of the start and end cells. It is guaranteed that the number is even.
Output Format: For each test case, print one integer in a separate line — the minimum amount of energy that will have to be spent to get from the cell with coordinates to the cell with coordinates .