#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007  
#define pb push_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mapit(i,mp) for(auto i = mp.begin(); i!=mp.end(); i++)
#define pii pair<int,int>

int cte[100001] ;
int cto[100001] ;
 
void solve(){
    int n;
       cin>>n;
       int a[n];
       fr(i,0,n){
            cin>>a[i];
       }
 
       int b[n];
 
       fr(i,0,n){
            b[i] = a[i];
       }
 
       sort(b,b+n);
 
 
       for(int i = 0; i<n; i++){
            if(i%2 == 0){
                cte[a[i]]++;
            }else{
                cto[a[i]]++;
            }
       }
 
       bool flag = true;
 
       for(int i = 0; i<n; i++){
            if(i%2 == 0){
                if(cte[b[i]] == 0){
                    flag = false;
                    break;
                }
                cte[b[i]]--;
            }else{
                if(cto[b[i]] == 0){
                    flag = false;
                    break;
                }
                cto[b[i]]--;
            }
       }
 
       if(flag){
            cout<<"YES"<<"\n";
       }else{
            cout<<"NO"<<"\n";
       }
}
 
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    int t = 1;
    cin>>t;    
   while(t--)
   {
        fr(i,0,100001){
            cte[i] = 0;
        }

         fr(i,0,100001){
            cto[i] = 0;
        }

        solve();
   }
   return 0;
}