#include <bits/stdc++.h>

#define ed end()
#define bg begin()
#define mp make_pair
#define pb push_back
#define all(x) x.bg,x.ed
#define newline puts("")
#define si(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5+10;
const int inf = 0x7f7f7f7f;
const int Mod = 1e9+7;
const double eps = 1e-7;
int cnt[maxn][2];
int a[maxn];

int main(){
    int T;
    scanf("%d",&T);
    for(int _=1;_<=T;_++)
    {
        int n;
        scanf("%d",&n);
        for (int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            cnt[a[i]][i % 2] ++;
        }
        sort(a+1,a+n+1);
        for (int i=1;i<=n;i++)
        {
            cnt[a[i]][i % 2] --;
        }
        bool ok = 1;
        for (int i=1;i<=n;i++)
        {
            if(cnt[a[i]][0]!=0 || cnt[a[i]][1]!=0){
                ok = 0;break;
            }
        }
        puts(ok?"YES":"NO");
        for (int i=1;i<=n;i++)
        {
            cnt[a[i]][0] = cnt[a[i]][1] = 0;
        }
    }
    return 0;
}