#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define int long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
const int N = 1e5+10;
int cnt[N][2],n,t,a[N];
bool solve()
{
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]][i%2]--;
		if(cnt[a[i]][i%2]<0) return false;
	}
	return true;
}
signed main()
{
	ios::sync_with_stdio(false),cin.tie(0);

	cin>>t;
	while(t--)
	{
		memset(cnt,0,sizeof cnt);
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			cnt[a[i]][i%2]++;
		}
		if(solve()) cout<<"YES"<<'\n';
		else cout<<"NO"<<'\n';
	}
}
