#include <bits/stdc++.h>
using namespace std;

void solve(vector<int64_t> p) {
    const int64_t N = p.size();
    vector<int64_t> ans;
    while (true) {
        int64_t target = 0;
        while (target < N && p[target] == target) {
            //すでに整頓済みだったら終わり
            target++;
            continue;
        }

        if (target == N) {
            break;
            ;
        }

        //整列
        //現在位置を探す
        int64_t curr_pos = 0;
        while (p[curr_pos] != target) {
            curr_pos++;
        }

        if (curr_pos == target) {
            break;
        }

        if (ans.size() % 2 == 0) {
            //偶数番目の位置を選んでスワップ可能
            if (curr_pos % 2 == 0) {
                int64_t i = (p.size() % 2 == 0 ? p.size() - 2 : p.size() - 3);
                swap(p[i], p[i + 1]);
                ans.push_back(i + 1);
            } else {
                curr_pos--;
                swap(p[curr_pos], p[curr_pos + 1]);
                ans.push_back(curr_pos + 1);
            }
        } else {
            //奇数番目の位置を選んでスワップ可能
            if (curr_pos % 2 == 1) {
                int64_t i = (p.size() % 2 == 0 ? p.size() - 3 : p.size() - 2);
                swap(p[i], p[i + 1]);
                ans.push_back(i + 1);
            } else {
                curr_pos--;
                swap(p[curr_pos], p[curr_pos + 1]);
                ans.push_back(curr_pos + 1);
            }
        }
    }

    for (int64_t i = 0; i < N; i++) {
        assert(p[i] == i);
    }
    cout << ans.size() << endl;
    assert(ans.size() <= N * N);
    for (int64_t i = 0; i < ans.size(); i++) {
        cout << ans[i] << " \n"[i == ans.size() - 1];
        assert(i % 2 == 1 || (ans[i] % 2 == 1 && 1 <= ans[i] && ans[i] <= N - 1));
        assert(i % 2 == 0 || (ans[i] % 2 == 0 && 2 <= ans[i] && ans[i] <= N - 1));
    }
}

int main() {
    int64_t T;
    cin >> T;
    while (T--) {
        int64_t N;
        cin >> N;
        vector<int64_t> p(N);
        for (int64_t& i : p) {
            cin >> i;
            i--;
        }
        solve(p);
    }
}
#include<bits/stdc++.h>
 
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define int long long int
 
#define pb push_back
#define mpp make_pair
#define F first
#define S second
#define vec vector <int>
#define pr vector<pair<int,int>> 
#define vecv vector <vec>
#define vecs vector <string>
#define vecc vector <char>
 
#define pi 3.141592653589793238
#define mod 1000000007
#define Mod 998244353
#define inf 1e16
#define precise(i) cout<<fixed << setprecision(i);
#define endl "\n"
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define one cout<<-1<<endl;

#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;
#define loop(a) for(auto xyz:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=b;i>=a;i--)

const long double eps = 1e-8;

#define lb lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define ub upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 
using namespace std;


void solve(){
    int n;
    cin>>n;
    int arr[n];
    f(i,0,n)cin>>arr[i];
    sort(arr,arr+n);
    f(i,1,n+1){
        if(arr[i-1]!=i){
            no;
            return;
        }
    }
    yes;
}

signed main() {
    fastio;
    int t=1;
    while(t--){
        solve();
    }
}