#include <bits/stdc++.h>

using namespace std;

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

int n , a[N] , b[N] , sum[3][N];

void pre()
{
    for(int i=1; i<N; i++)
    {
        sum[i%2][i]++;
        sum[0][i] += sum[0][i-1];
        sum[1][i] += sum[1][i-1];
    }
}

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

    pre();
    int t;
    cin >> t;
    while(t--)
    {
        map<ll,ll> mn , mx;
        map<ll,ll> mp[3];

        set<ll> st;
        cin >> n;
        for(int i=1; i<=n; i++)
        {
            cin >> a[i] , b[i] = a[i];
            st.insert(a[i]);
            mp[i%2][a[i]]++;
        }

        sort(b+1 , b+n+1);
        for(int i=1; i<=n; i++)
        {
            if (!mn.count(b[i]))
                mn[b[i]] = i , mx[b[i]] = i;
            else mx[b[i]] = i;
        }

        bool ans=1;
        for(auto it : st)
        {
            int od = mp[1][it] , ev = mp[0][it],
            l = mn[it] , r = mx[it];
            int smOd = sum[1][r] - sum[1][l-1] , sumEv = sum[0][r] - sum[0][l-1];
            if (od == smOd && ev == sumEv) continue;
            else ans=0;
        }

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


    return 0;
}