#include <bits/stdc++.h>

#define X first
#define Y second
#define fi first
#define se second
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)(x).size()
#define int long long

/*
    continue break front push size empty begin insert unsigned lower_bound upper_bound resize emplace_back priority_queue
*/
using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vi = vector<int>;
using ti = tuple<int, int, int>;
using ull = unsigned long long;
const int MOD = 1e9+7;
//const int MAX = 101010;
const int INF = 1e9+7;
//const ll INF = 2e15;
const int ALP=26;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int n;

void solve(){
    cin>>n;
    vector<int> a(n), b(n);
    rep(i,0,n){
        cin>>a[i];
        b[i] = a[i];
    }
    sort(all(b));
    vector<vi> cnt(2, vi(101010, 0));
    rep(i,0,n){
        cnt[i%2][a[i]]++;
        cnt[i%2][b[i]]--;
    }
    rep(i,0,101010){
        rep(j,0,2){
            if(cnt[j][i]){
                cout<<"NO\n";
                return;
            }
        }
    }
    cout<<"YES\n";
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(NULL);
    int tc;cin>>tc;
    for(int i=1;i<=tc;++i)
        solve();
    
    return 0;
}