#include <iostream>
#include<bits/stdc++.h>
using namespace std;

#define ll long long 

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 
	 int t;
	 cin>>t;
	 while(t--){
	     
	  ll n;
	  cin>>n;
	  
	  ll a[n];
	  pair<ll,ll> ss[100001], ss1[100001];
	  
	
	  for(int i=0;i<n;++i)
	  cin>>a[i];
	  
	  for(int i=0;i<n;++i){
	      ss[a[i]]={0,0};
	      ss1[a[i]]={0,0};
	  }
	  
	  for(int i=0;i<n;++i){
	   if(i&1)
	  ss[a[i]].second++;
	      else
	      ss[a[i]].first++;}
	  
      sort(a,a+n);
      
      for(int i=0;i<n;++i){
	  if(i&1)
	  ss1[a[i]].second++;
	      else
	      ss1[a[i]].first++;
	  }
	  
	  set<ll> st;
	  int f=0;
	  
	  for(int i=0;i<n;++i)
	  st.insert(a[i]);
	  
	  for(auto i:st){
	      if(ss[i].first!=ss1[i].first || ss[i].second!=ss1[i].second){
	         f=1;
	          break;
	      }
	  }
	  
      if(f)
      cout<<"NO"<<"\n";
      else
      cout<<"YES"<<"\n";
	  
	 }
	return 0;
}