342 and Xiangqi
题号:NC237056
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

342 likes playing Xiangqi (as it's called Chinese chess). His favorite piece in Xiangqi is "Xiang" because his opponents usually overlook the existence of Xiang so their major pieces are often taken by 342's Xiang.
For those of you who don't know how Xiang moves in Xiangqi, Xiang is a minor piece that each player initially has two, located at the position 3 and 6 respectively. The number for each position is showed in the illustration bellow. In a single move, Xiang should move 2 squares horizontally as well as vertically. But note that it can neither move out of the half board nor it can overlap with other pieces. The illustration below showed all the 7 possible positions that Xiang could reach. For example, in a single move,


  • A Xiang at position 2 can move to position 4,
  • A Xiang at position 7 can move to position 6,
  • A Xiang at position 3 cannot move to position 5.
342 has 2 Xiangs as the only 2 pieces in the half board. Their present positions are given and guaranteed to be 2 different positions out of the 7 possible ones. But 342 disliked the present positions of his 2 Xiangs and would like to adjust their positions by a few moves. In each move, he can choose one of the Xiangs and move it following the rules explained. The final positions 342 want are also given and guaranteed to be 2 different positions out of the 7 possible ones. Note that the 2 Xiangs are considered the same, meaning that he doesn't restrict that which of the 2 Xiangs has to move to which of the 2 positions.

Now 342 wonders, at least how many moves he need to adjust the 2 Xiangs from the present positions to the final positions that 342 want?

输入描述:

The first line contains a single integer  -- the number of test cases.
This is followed by T lines, representing each test case, each containing a single line of four integers a_1,a_2,b_1,b_2 such that a_1, a_2 represent the present positions of the 2 Xiangs while b_1,b_2 represent the final positions of them.

输出描述:

For each test case, print a single integer: the least number of moves that 342 needs to adjust his 2 Xiangs to the final positions, considering the 2 Xiangs to be the same?
示例1

输入

复制
3
1 5 1 7
2 7 4 6
2 3 3 2

输出

复制
1
2
0