#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t1;
    cin >> t1;
    for (int q11 = 0; q11 < t1; q11++){
        int n;
        cin >> n;
        vector<p> a(n);
        for (int q = 0; q < n; q++){
            cin >> a[q].first;
            a[q].second = q;
        }
        sort(a.begin(), a.end());
        int q1 = 0;
        bool flag = true;
        while (q1 < a.size()){
            int q2 = q1, is0 = 0, is1 = 0, need0 = 0, need1 = 0;
            while (q2 < a.size() && a[q2].first == a[q1].first){
                if (q2 % 2 == 0){
                    is0++;
                }else{
                    is1++;
                }
                if (a[q2].second % 2 == 0){
                    need0++;
                }else{
                    need1++;
                }
                q2++;
            }
            flag &= (is0 == need0), q1 = q2;
        }
        cout << (flag ? "YES" : "NO") << endl;
    }
    return 0;
}
