#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
vector<int> a;
vector<int> aa[maxn];
vector<int>b;
vector<int> bb[maxn];
//int vis[maxn];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;cin>>t;
    while(t--){
            a.clear();
            b.clear();
            for(int i=1;i<maxn;i++){
                aa[i].clear();
                bb[i].clear();
            }
            int n;cin>>n;
           for(int i=0;i<n;i++){
            int x;cin>>x;
            a.push_back(x);
            b.push_back(x);
           }
           sort(b.begin(),b.end());
           bool flag=true;
           for(int i=0;i<n;i++){
            aa[a[i]].push_back(i);
            bb[b[i]].push_back(i);
           }
           for(int i=1;i<maxn;i++){
            int su=0,si=0;
            for(int j=0;j<aa[i].size();j++){
                if(aa[i][j]&1)su++;
                if(bb[i][j]&1)si++;
            }
            if(su!=si){flag=false;break;}
           }
           cout<<(flag?"YES":"NO")<<endl;
    }
    return 0;
}
