//  
//  Created by LiZnB at 22:31:49 on 2021/09/13.
//

#include <algorithm>
#include <bits/stdc++.h>
#define int long long
//#define ONLINE_JUDGE
using namespace std;

void run() {
#ifdef ONLINE_JUDGE
#else
    freopen("in1.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
}
const int N = 1e6 + 10;


#define ls tree[pos].l
#define rs tree[pos].r


struct Tree {
    struct Node {
        int l, r;
        long long val;
    } tree[N * 4];
    
    long long lazy[N * 4];
    
    void Init(int n) {
        for (int i = 1; i <= n * 4; i++) {
            lazy[i] = 0;
        }
    }
    Tree() {
        memset(lazy, 0ll, sizeof(lazy));
    }
    
    void Build(int L, int R, int pos) {
        ls = L;
        rs = R;
        if (L == R) {
            tree[pos].val = 0;
            return;
        }
        int m = L + (R - L) / 2;
        Build(L, m, pos << 1);
        Build(m + 1, R, pos << 1 | 1);
        tree[pos].val = tree[pos << 1].val + tree[pos << 1 | 1].val;
    }
    
    void Down(int pos) {
        if (lazy[pos] != 0) {
            tree[pos << 1].val += (tree[pos << 1].r - tree[pos << 1].l + 1) * lazy[pos];
            tree[pos << 1 | 1].val += (tree[pos << 1 | 1].r - tree[pos << 1 | 1].l + 1) * lazy[pos];
            lazy[pos << 1] += lazy[pos];
            lazy[pos << 1 | 1] += lazy[pos];
            lazy[pos] = 0;
        }
    }
    
    void Modify(int pos, int L, int R, long long val) {
        if (rs <= R && ls >= L) {
            tree[pos].val += 1ll * (rs - ls + 1) * val;
            lazy[pos] += val;
            return;
        }
        Down(pos);
        int m = ls + (rs - ls) / 2;
        if (L <= m) Modify(pos << 1, L, R, val);
        if (R > m) Modify(pos << 1 | 1, L, R, val);
        tree[pos].val = tree[pos << 1].val + tree[pos << 1 | 1].val;
    }
    
    long long Query(int pos, int L, int R) {
        if (ls >= L && rs <= R) {
            return tree[pos].val;
        }
        Down(pos);
        int m = ls + (rs - ls) / 2;
        long long ans = 0ll;
        if (m >= L) ans += Query(pos << 1, L, R);
        if (m < R) ans += Query(pos << 1 | 1, L, R);
        tree[pos].val = tree[pos << 1].val + tree[pos << 1 | 1].val;
        return ans;
    }
} T;

int res[N], arr[N];
map<int, int> odd[2], even[2];

signed main() {
    run();
    int z; cin >> z;
    while (z--) {
        odd[0].clear(), even[0].clear();
        odd[1].clear(), even[1].clear();

        int n;
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> arr[i];
            res[i] = arr[i];
        }
        sort(res + 1, res + n + 1);
        for (int i = 1; i <= n; i++) {
            if (i & 1) odd[0][arr[i]]++, odd[1][res[i]]++;
            else even[0][arr[i]]++, even[1][res[i]]++;
        }
        int flag = true;
        for (int i = 1; i <= n; i++) {
            if (odd[0][res[i]] != odd[1][res[i]]) flag = false;
            if (even[0][res[i]] != even[1][res[i]]) flag = false;
        }
        if (flag) cout << "YES" << endl;
        else cout << "NO" << endl;

    }
    return 0;
}
