#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main(){
	int t;
	cin>>t;
	while(t--)
	{
	int n;
	cin>>n;
	vector<int> x(n),y(n);
	map<int,pair<int,int>> a,b;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
		if(i%2==1)
		a[x[i]].first++;
		else a[x[i]].second++;
	}	
	sort(x.begin(),x.end());
	for(int i=0;i<n;i++)
	{
		if(i%2==1)
		b[x[i]].first++;
		else b[x[i]].second++;
	}
	bool flag  = true;
	for(int i=0;i<n;i++)
	{
		int j = x[i];
		if(a[j].first == b[j].first && a[j].second == b[j].second)
		continue;
		else
		{
			flag = false;
			break;
		}
	}
	if(flag) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}