#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
int T;
char s[100100];
int a[100100];
int t[100100];
int cnt[100100];
void init()
{
	memset(t,0,sizeof(t));
	memset(cnt,0,sizeof(cnt));
}
int main ()
{
	cin>>T;
	while(T--)
	{
		init();
		int n;
		scanf("%d",&n);
		rep(i,1,n) 
		{
			scanf("%d",a+i);
			t[a[i]]+=i;
			if(i%2==1)
			cnt[a[i]]++;
		}
		sort(a+1,a+1+n);
		rep(i,1,n)
		{
			t[a[i]]-=i;
			if(i%2==1)
			cnt[a[i]]--;
		}
		bool fl=1;
		rep(i,1,100000)
		if(abs(t[i])%2==1||cnt[i]!=0)
		{
			fl=0;
			break;
		}
		if(fl) printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}
