You are given an array a consisting of n integers (it is guaranteed that n is even, i.e. divisible by 2). All ai does not exceed some integer k.
Your task is to replace the minimum number of elements (replacement is the following operation: choose some index i from 1 to n and replace ai with some integer in range [1;k]) to satisfy the following conditions:
after all replacements, all ai are positive integers not greater than k;
for all i from 1 to n2 the following equation is true: ai+an−i+1=x, where x should be the same for all n2 pairs of elements.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1≤t≤104) — the number of test cases. Then t test cases follow.
The first line of the test case contains two integers n and k (2≤n≤2⋅105,1≤k≤2⋅105) — the length of a and the maximum possible value of some ai correspondingly. It is guratanteed that n is even (i.e. divisible by 2). The second line of the test case contains n integers a1,a2,…,an (1≤ai≤k), where ai is the i-th element of a.
It is guaranteed that the sum of n (as well as the sum of k) over all test cases does not exceed 2⋅105 (∑n≤2⋅105, ∑k≤2⋅105).
Output
For each test case, print the answer — the minimum number of elements you have to replace in a to satisfy the conditions from the problem statement.
Example
inputCopy
4
4 2
1 2 1 2
4 3
1 2 2 1
8 7
6 1 1 7 6 3 4 6
6 6
5 2 6 1 3 4
outputCopy
0
1
4
2
int lowbit(int x) {
return x&-x;
}
void add(int x,int d) {
for(int i=x; i<=2*k; i+=lowbit(i))
tr[i]+=d;
}
ll sum(int x) {
ll res=0;
for(int i=x; i; i-=lowbit(i))
res+=tr[i];
return res;
}
int main() {
scanf( "%d", &t );
while(t--) {
scanf( "%d%d",&n, &k );
map<int,int> mp;
for(int i=1; i<=2*k; i++)
tr[i]=0;
for(int i=1; i<=n; i++)
scanf( "%d",&a[i] );
ll res=0;
for(int i=1; i<=n/2; i++) {
l[i]=min(a[i],a[n-i+1])+1;
r[i]=max(a[i],a[n-i+1])+k;
int s=a[i]+a[n-i+1];
add(1,2);
add(l[i],-2);
add(l[i],1);
add(s,-1);
add(s+1,1);
add(r[i]+1,-1);
add(r[i]+1,2);
}
res=0x3f3f3f3f;
for(int i=2; i<=2*k; i++)
res=min(res,sum(i));
cout<<res<<endl;
}
return 0;
}