#include<bits/stdc++.h>
#include<math.h>

using namespace std;

#define ll long long

#define endl "\n"

#define pb push_back

#define eraseO(s, x) if(s.find(x) != s.end()) { s.erase(s.lower_bound(x)); }

#define vi vector<int>

#define vc vector<char>

#define vl vector<ll>

#define ip pair<int, int>

#define cip pair<int, char>

#define vip vector<ip>

#define msi multiset<int>

#define REP(d, i) for(int i = 0; i < d; ++i)

#define REPD(d, i) for(int i = d - 1; i >= 0; i--)

#define REPM(d, d1, i, j) for(int i = 0; i < d; ++i){for(int j = 0; j < d1; ++j)

#define REPV(v, i) REP(v.size(), i)

#define REPVD(v, i) REPD(v.size(), i)

#define FOR(d) REP(d, i)

#define FORD(d) REPD(d, i)

#define FORM(d, d1) REPM(d, d1, i, j)

#define FORV(v) REPV(v, i)

#define FORVD(v) REPVD(v, i)

#define INA(a, d) FOR(d) { cin >> a[i]; }

#define INM(a, d, d1) FORM(d, d1) { cin >> a[i][j];}}

#define OUTA(a, d) FOR(d) { cout << a[i] << " "; }

#define OUTV(a) FORV(a) { cout << a[i] << " "; }

#define OUTM(c, d, d1) FORM(d, d1) { cout << c[i][j] << " "; } cout << endl;}

void solve() {

    int n;
    cin >> n;

    map<int, int> oc1;
    map<int, int> ec1;
    map<int, int> oc2;
    map<int, int> ec2;

    set<int> nums;

    int a[n];
    INA(a, n);

    FOR(n) {
        if(i % 2) {
            oc1[a[i]]++;
        } else {
            ec1[a[i]]++;
        }
        nums.insert(a[i]);
    }
    sort(a, a + n);

    FOR(n) {
        if(i % 2) {
            oc2[a[i]]++;
        } else {
            ec2[a[i]]++;
        }
    }

    bool ok = 1;

    for(int i : nums) {
        if(oc1[i] != oc2[i] || ec1[i] != ec2[i]) {
            ok = 0;
        }
    }

    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    FOR(t) {
        solve();
    }
}
