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



void solve(){
    int n;
	    cin >> n;
	    
	    int a[n];
	    unordered_map<int, pair<int,int>> mp;
	
	    
	    for(int i = 0;i<n;i++){
	        cin >> a[i];
	        
	        if(i%2)mp[a[i]].second++;
	        else mp[a[i]].first++;
	        
	    }
	   
	 
	    sort(a,a+n);
	    
	    for(int i = 0;i<n;i++){
	        if(i%2){
	            mp[a[i]].second--;
	            if(mp[a[i]].second == -1){
	                cout << "NO" << endl;
	                return ;
	            }
	        }
	        else{
	            mp[a[i]].first--;
	            if(mp[a[i]].first == -1){
	                cout << "NO" << endl;
	                return ;
	            }
	        }
	    }
	    
	   
	    cout << "yes" << endl;
}
int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t;
	cin >> t;
	
	while(t--){
	    solve();
	}
	return 0;
}
