#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define f(a,n) for(int i=a;i<n;i++)
#define fl(a,n) for(ll i=a;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define lld long double
using namespace std;
 
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    
    while(t--)
    { ll n;
      cin>>n;
      ll a[n],b[n];
      map<ll,ll> m,f;
      
      for(ll i=0;i<n;i++)
      {cin>>a[i];
      if((i+1)%2==0)
      f[a[i]]++;
      else
      f[a[i]]--;
      b[i]=a[i];
      }
      sort(b,b+n);
      for(ll i=0;i<n;i++)
       {if((i+1)%2==0)
       m[b[i]]++;
       else
       m[b[i]]--;}
       
      ll k=0;
      for(auto it:m)
      { if(f[it.first]-it.second==0)
         k++; 
      }
      if(k==m.size())
      cout<<"YES"<<endl;
      else
      cout<<"NO"<<endl;
    }
   
}