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

#define int long long //int main to signed main (Avoid if TC very close to limit)
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void setIO(string s="") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (sz(s)) {
        freopen((s+".in").c_str(),"r",stdin);
        freopen((s+".out").c_str(),"w",stdout);
    }
}

//Imp consts
const int MOD=1e9+7;
const int MAXN=1e5+1;
const int INF=1e18+5;
const double pi=3.14159265358979323846;
const double ep=1e-20;

signed main()
{
    setIO();
    int t=1;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        bool ok=1;
        int a[n];
        vector<vector<int>> cnt(MAXN,vector<int>(2)),cnt1(MAXN,vector<int>(2));
        for(int i=1;i<=n;i++) {
            cin>>a[i-1];
            cnt[a[i-1]][(i%2)]++;
        }
        sort(a,a+n);
        for(int i=0;i<n;i++)
            cnt1[a[i]][((i+1)%2)]++;
        cout<<(cnt==cnt1?"YES\n":"NO\n");
    }
    return 0;
}
