While climbing the towers of Winterfell, Bran Stark came across an array consisting of Westerosi letters. As is known, the Westerosi alphabet consists of letters arranged in a circle, each characterized by an integer a_i.
Looking at the array, Bran decided to turn it into a palindrome, after first shuffling the letters in any order. In one operation, he can replace any letter in the array with the next letter in the alphabet clockwise or counterclockwise. When he replaces a letter with the next one clockwise, it becomes letter i+1, and letter becomes . Similarly, when replacing a letter with the next one counterclockwise, it becomes letter i-1, and letter becomes .
Lady Catelyn Stark has already set out to search for her son, so Bran wants to achieve the goal in the minimum possible number of operations, and he asks you to tell him this number.
The first line contains an integer (1 \le t \le 10^4) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (1 \le n \le 4 \cdot 10^5, 1 \le m \le 2 \cdot 10^5) — the length of the array and the number of letters in the alphabet.
The next line contains an array of integers of length (1 \le a_i \le m) — the array Bran Stark came across.
It is guaranteed that the sum of over all test cases does not exceed 4 \cdot 10^5.
For each query, output one number — the minimum number of the described operations required to transform the array into a palindrome.
Example 1
Example 2
Explanation for the first test case
In the first example, one can first shuffle the letters into the order [2,4,6,9,7,5,2], then move the second letter clockwise and the fifth letter counterclockwise, obtaining the array [2,5,6,9,6,5,2], which is a palindrome.
In the second example, after first shuffling the letters into the order [1,3,2,1,1,3,3,1], and then moving the third letter clockwise, we obtain the array [1,3,3,1,1,3,3,1], which is a palindrome.
Subtask ( points): (n\le 10)
Subtask ( points): (m \le 2)
Subtask ( points): — even)
Subtask ( points): (n \le 100)
Subtask ( points): No additional constraints