Queen move!
There are 8 queens are placed arbitrarily on a chessboard 8х8. Each horizontal line contains only one queen and there is no other chess pieces. The Queen can move any number of cells diagonally, vertically or horizontally, but can not jump over other pieces. You must make the minimum number of moves to achieve the position where no queen is under the attack of the other.
Input
The first positive integer T (T < 6) is the number of test cases. Then T blocks are given, each of them contains 8 integers from 1 to 8 – the numbers of horizontals where the queen from the i-th vertical is situated. The verticals are numbered one after another. All numbers are given in one line, separated with a space.
Output
Print in one line for each test case one number - the minimum number of queen moves to achieve the desired position. Do not print spaces between the numbers.