#include<iostream>
#include <bits/stdc++.h>
#include<cmath>
#include <algorithm>
#include<string>
using namespace std;

int main(){
  long long int t; cin>>t;
  for(long long int l=0;l<t;l++){
    int n; cin>>n;
    int a[n],sorted[n];
    for(int i=0;i<n;i++){cin>>a[i];sorted[i]=a[i];}
    sort(sorted,sorted+n);
    int c1[100001],c2[100001];
    for(int i=0;i<=100000;i++){c1[i]=0;c2[i]=0;}
    for(int i=0;i<n;i++){
      if(i%2==0)c1[a[i]]++;
      if(i%2==0)c2[sorted[i]]++;
    }
    bool possible=true;
    for(int i=0;i<=100000;i++)if(c1[i]!=c2[i]){possible=false; break;}
    if(possible)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
