
There are queens placed arbitrarily on an 8 \times 8 chessboard. Each column contains exactly one queen, and there are no other pieces on the board. A queen can move any number of squares vertically, horizontally or diagonally, but cannot jump over other pieces. Your task is to reach a position where no queen is under attack by another, using the minimum number of moves.
The first line contains a positive integer (T < 6) — the number of test cases. Next follow blocks, each consisting of integers from to , where the -th integer gives the row of the queen in the -th column. The columns are numbered from to . All numbers in a block are given in a single line, separated by spaces.
For each test case, print a single number on a separate line — the minimum number of moves required to achieve the desired position.
Example 1