#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<fixed<<setprecision(10)<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout << fixed << setprecision(15); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on

#ifdef ONLINE_JUDGE
void dbg(vector<ll> &p, ll j) {}
#else
void dbg(vector<ll> &p, ll j) {
    ll n = p.size() - 1;
    for (ll i = 1; i <= n; i++) {
        perr0(p[i], " ");
    }

    if (j > 0) {
        perr("!", j, "!");
    } else {
        perr();
    }
}
#endif

void output(vector<ll> &ops) {
    ll m = ops.size();
    print(m);
    for (ll i = 0; i < m; i++) {
        if (i > 0) print0(" ");
        print0(ops[i]);
    }
    print();
}
void op(vector<ll> &ops, vector<ll> &p, bool &even, ll i) {
    //    perr(i);
    swap(p[i], p[i + 1]);
    ops.push_back(i);
    even = !even;
    dbg(p, i);
}

void solve3(ll n, vector<ll> &p, bool even0, vector<ll> &ops) {
    bool even = even0;
    while (true) {
        if (p[1] == 1 && p[2] == 2 && p[3] == 3) {
            break;
        }
        if (even) {
            op(ops, p, even, 2);
        } else {
            op(ops, p, even, 1);
        }
    }
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> p(n + 1);
    for (ll i = 1; i <= n; i++) {
        cin >> p[i];
    }

    if (n == 2) {
        vector<ll> ops2;
        if (p[1] == 2) {
            ops2.push_back(1);
        }
        output(ops2);
        return;
    }

    vector<ll> ops;
    ll searchval = n;
    bool even = false;
    while (true) {
        if (searchval == 3) {
            solve3(3, p, even, ops);
            break;
        }
        ll searchi = -1;
        for (ll i = 1; i <= n; i++) {
            if (p[i] == searchval) {
                searchi = i;
                break;
            }
        }
        if (searchi == searchval) {
            searchval--;
            continue;
        }
        bool cureven = (searchi % 2 == 0);
        if (cureven && !even) {
            if (searchi == 2) {
                op(ops, p, even, 1);
                op(ops, p, even, 2);
                searchi = 1;
            } else {
                op(ops, p, even, 1);
            }
        } else if (!cureven && even) {
            if (searchi == 3) {
                op(ops, p, even, 2);
                op(ops, p, even, 1);
                op(ops, p, even, 2);
                searchi = 1;
            } else {
                op(ops, p, even, 2);
            }
        }
        for (ll i = searchi;; i++) {
            if (i >= searchval) break;
            op(ops, p, even, i);
        }
        searchval--;
    }
    output(ops);
}
int main() {
    ioinit();
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve(){
    int n;
    cin >> n;
    vi v(n), w(n);
    F0R(i, n){
        cin >> v[i];
    }
    F0R(i, n){
        cin >> w[i];
    }
    int ans = 0;
    F0R(i, n){
        ans += (v[i] * w[i]);
    }
    if(ans == 0){
        cout << "Yes" << nl;
    }
    else{
        cout << "No" << nl;
    }
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
