
#include <bits/stdc++.h>

using namespace std;

#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 3e5+5;

int n , a[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    cin >> t;
    while(t--)
    {
        map<int,int> mp[2];
        cin >> n;
        for(int i=1; i<=n; i++)
            cin >> a[i] , mp[i%2][a[i]]++;

        sort(a+1 , a+n+1);
        for(int i=1; i<=n; i++)
        {
            mp[i%2][a[i]]--;
        }

        bool ans=1;
        for(int i=1; i<=n; i++)
        {
            if (mp[0][a[i]] != 0 || mp[1][a[i]] != 0) ans=0;
        }

        if (ans) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}
