
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    map <int, int> cnt;
    for (int i = 0; i < n; i++)
        cnt[a[i]] += i % 2;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++)
        cnt[a[i]] -= i % 2;

    for (auto& kv : cnt) {
        if (kv.second != 0) {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}
