#include<bits/stdc++.h>
#include<string.h>
using namespace std;
//#define mx 1000
#define ll long long int	
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define pu push
#define po pop
#define ins insert
#define srt(v)  sort(v.begin(),v.end())
#define rep(i, a, b) for (int i=a; i<b; i++)
#define rep2(i, a, b) for (int i=a; i>=b; i--)
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,1,sizeof(a))
/*
ll invfact(int n1){	
    ll va=fact[n1];
    //cout<<va<<" ";
    ll p=mod-2;
    ll res=1;
    while(p!=0){
    	if(p%2==1){
    		res=((res%mod)*(va%mod))%mod;}
    	va=((va%mod)*(va%mod))%mod;
    	p=p/2;
	}
	return res%mod;
}
*/
/*
map<int, vector<int> >adj;
map<int,int>pa;
vector<int>v;
vector<ll>dp;
void dfs(int st,int p){
	pa[st]=p;
	if(adj[st].size()==1&&adj[st][0]==p){
		dp[st]=1;
	    v.push_back(st);
	}
	for(int i=0;i<adj[st].size();i++){
		if(adj[st][i]!=p)
		dfs(adj[st][i],st);}
}
*/
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<int,map<int,int> >M1;
		map<int,map<int,int> >M2;
		vector<int>v(n);
		vector<int>te(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
			te[i]=v[i];
			M1[v[i]][i%2]+=1;}
		sort(te.begin(),te.end());
		for(int i=0;i<n;i++){
			M2[te[i]][i%2]+=1;}
		int fl=1;
		for(int i=0;i<n;i++){
			if(M1[v[i]][0]!=M2[v[i]][0]||M1[v[i]][1]!=M2[v[i]][1]){
				fl=0;
				break;
			}
		}
		if(!fl)
		cout<<"NO"<<endl;
		else
		cout<<"YES"<<endl;
	}
}

