#include <bits/stdc++.h>
using namespace std;
    
#define pb push_back
#define MP make_pair
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

#define fo(i,a,b) for(int i=a;i<b;i++)
#define rfo(i,b,a) for(int i=b;i>=a;i--)

typedef vector<ll> vi;
typedef vector<vi> vvi;

 string solve(){
   ll n;
   cin>>n;
   vi a(n);
   map<int,int> m;
   
   fo(i,0,n){
       cin>>a[i];
       m[a[i]] = m[a[i]]  + (i%2);
   }
   sort(a.begin(), a.end());
   fo(i,0,n){
       m[a[i]] = m[a[i]]-(i%2);
   }
   map<int,int> :: iterator itr;
   for(itr = m.begin() ; itr!= m.end() ; itr++){
       if(itr->second != 0) return "NO";
   }
   return "YES";
    
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
	cin>>t;
	while(t--)
	{
		cout<<solve()<<endl;
	}
	return 0;
}
