#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a),i##ss=(b);i<=i##ss;i++)
#define dwn(i,a,b) for(int i=(a),i##ss=(b);i>=i##ss;i--)
#define deb(x) cerr<<(#x)<<":"<<(x)<<'\n'
#define pb push_back
#define fi first
#define se second
#define hvie '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
int yh(){
	int ret=0;bool f=0;char c=getchar();
	while(!isdigit(c)){if(c==EOF)return -1;if(c=='-')f=1;c=getchar();}
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c^48),c=getchar();
	return f?-ret:ret;
}
const int maxn=3e5+5;
int a[maxn];
int oca[maxn][2],ocb[maxn][2];
int main(){
	dwn(_,yh(),1){
		int n=yh();
		rep(i,1,n) a[i]=yh(),oca[a[i]][i&1]++;
		sort(a+1,a+1+n);
		rep(i,1,n) ocb[a[i]][i&1]++;
		bool bad=0;
		rep(i,1,n){
			if(oca[a[i]][0]!=ocb[a[i]][0]||oca[a[i]][1]!=ocb[a[i]][1]){
				bad=1;
				break;
			}
		}
		if(bad)puts("NO");else puts("YES");
		rep(i,1,n) oca[a[i]][0]=ocb[a[i]][0]=oca[a[i]][1]=ocb[a[i]][1];
	}
	return 0;
}
