#include<bits/stdc++.h> // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp> // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp> // all set fnct + = 1. order_of_key(x); //number
#define ll long long //of element strictly smaller than it;
#define ld long double // 2. find_by_order(x),pointer el at x pos after sort use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.flush();
ll t=1;
cin>>t;
while(t--)
{
ll n,k;
cin>>n>>k;
ll a[200001];
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
ll ans=0;
ll In[200002];
ll Ins[200001];
ll S[200001];
memset(S,0,sizeof(S));
memset(Ins,0,sizeof(Ins));
memset(In,0,sizeof(In));
for(ll i=1;i<=n;i++)
{
Ins[a[i]]++;
In[a[i]]++;
}
for(ll i=1;i<=n/2;i++)
{
ll s= a[i]+a[n-i+1];
S[s]++;
}
for(ll i=200000;i>=0 ;i--)
{
In[i]=In[i+1]+In[i]; // largerequal top sum i;
}
for(ll i=1;i<=200000;i++)
{
Ins[i]=Ins[i-1]+Ins[i]; // smaller than or equal top sum i;
}
ll A;
ans = LLONG_MAX;
for(ll i=1;i<=n/2;i++)
{
ll s = a[i]+a[n-i+1];
A = n-(S[s]*2);
A=A/2;
ll p = s - k;
if(p-1>=0)
A = A + Ins[p-1];
ll xx = s;
if(xx>0)
A=A+ In[xx] ;
ans = min(ans,A) ;
// cout<<"A: "<<A<<endl;
}
cout<<ans<<endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4gICAgICAgICAgICAgICAgICAgLy8gYmVsb3cgY29tbWVudCBmb3IgcGJkcwojaW5jbHVkZTxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4gICAvLyB0byB1c2UgaXQgbWFrZSBvcmRlcmVkX3NldAojaW5jbHVkZTxleHQvcGJfZHMvdHJlZV9wb2xpY3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