#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define ff first
#define pii pair<int,int>
#define ss second
#define pp make_pair
#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define PI 3.1415926535 
#define mst(v, x) memset(v, x, sizeof v);
#define all(v) v.begin(), v.end()
#define INF 2000000000
#define dpq priority_queue<int>
#define ipq priority_queue<int, vector<int>, greater<int>>
#define setbits(x)          __builtin_popcountll(x)
using namespace std;
void IOS(){ios::sync_with_stdio(false); cout.precision(10); cout << fixed;}
const int MOD = 1e9 + 7;

const int mx=1e5+1;
int i, j, k;
int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

int cnt[100001][2];

void solve(){
      int n;
      cin>>n;
      vector<int>ar(n);
      rep(i,n){
            cin>>ar[i];
            cnt[ar[i]][i%2]++;
      }
      sort(all(ar));
      rep(i,n)cnt[ar[i]][i%2]--;
      int f = 0;
      rep(i,n){
            if(cnt[ar[i]][0]!=0 || cnt[ar[i]][1]!=0){
                  cout<<"NO\n";
                  
                  f = 1;
                  break;
            }
      }
      if(!f)cout<<"YES\n";
      rep(i,n)cnt[ar[i]][0]=cnt[ar[i]][1] = 0;


}

int32_t main(){
	IOS();
      int t;
      cin>>t;
      while(t--)solve();
	
	return 0;
}



