#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

void solve() {
    int n;
    cin >> n;
    map<int, pair<int, int>> pos;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i % 2 == 0) {
            pos[a[i]].first++;
        }
        else {
            pos[a[i]].second++;
        }
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            pos[a[i]].first--;
        }
        else {
            pos[a[i]].second--;
        }
    }

    for (auto itr = pos.begin(); itr != pos.end(); ++itr) {
        if (itr -> second.first || itr -> second.second) {
            cout << "NO" << '\n';
            return;
        }
    } 

    cout << "YES" << '\n';
    return;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}