#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define trace(x) cerr<<#x<<": "<<x<<endl;
void dbg(){cerr<<"\n";}
template<typename T, typename... Types>
void dbg(T var1, Types... var2){cerr<<var1<<" ";dbg(var2...);}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tc,n,x,c0,c1,j;
    bool flag;
    cin>>tc;
    while(tc--){
    	flag=true;
    	cin>>n;
    	vector<pair<ll,ll>>a(n),b(n);
    	for(int i=0;i<n;i++){
    		cin>>a[i].first;
    		a[i].second=i%2;
    	}
    	b=a;
    	sort(b.begin(),b.end());
    	for(int i=0;i<n;i++){
    		b[i].second=i%2;
    	}
    	sort(a.begin(),a.end());
    	sort(b.begin(),b.end());
    	if(a==b){
	        cout<<"YES\n";
	    }
	    else{
	        cout<<"NO\n";
	    }
    }
	return 0;
}