#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

#define endl '\n'

const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
inline void fasterios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


// Don't forget to read all the inputs before returning!!!
int solve(){
  int n; cin >> n;
  vector <PII> arr(n);
  rep(i,0,n){
    cin >> arr[i].fi;
    arr[i].se = i;
  }
  sort(all(arr));
  vector <int> tmp[2];
  rep(i,0,n) if(abs(arr[i].se - i) % 2 == 1) tmp[i%2].pb(arr[i].fi);
  sort(all(tmp[0]));
  sort(all(tmp[1]));
  if(sz(tmp[0]) != sz(tmp[1])){
    cout << "NO" << endl;
    return 0;
  }
  for(int i = 0;i < sz(tmp[0]);i++){
    if(tmp[0][i] != tmp[1][i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

int main(){
  fasterios();
  int testCases; cin >> testCases; int tc = 0;
  while(++tc <= testCases){
    // cout << "Case #" << tc << ": ";
    solve();
  }
}