描述
Background
Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?
S先生是一位出名的国际象棋选手,他断言没人能比他更快地将一个骑士移向另一位置,你能打败他吗?
The Problem
Your task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from another, so that you have the chance to be faster than Somurolov.
For people not familiar with chess, the possible knight moves are shown in Figure 1.
你的任务是写一个程序计算将一个其实从一个点移向另一个点的最小步数,这样你就会有机会比S先生更快。对于不熟悉国际象棋的人,图1显示了骑士可能的动作。
输入
The input begins with the number n of scenarios on a single line by itself.
Next follow n scenarios. Each scenario consists of three lines containing integer numbers. The first line specifies the length l of a side of the chess board (4 <= l <= 300). The entire board has size l