/*
 * author: zhaoyiping
 * time: 2021-07-11 22:06:53
 */
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &x : v)
      cin >> x;
    map<int, vector<int>> ma;
    for (int i = 0; i < n; i++)
      ma[v[i]].push_back(i);
    int cnt = 0;
    bool flag = true;
    for (auto x : ma) {
      vector<int> tmp;
      int a = 0, b = 0;
      for (auto y : x.second) {
        a += y % 2;
        b += cnt % 2;
        cnt++;
      }
      if (a != b)
        flag = false;
    }
    puts(flag ? "YES" : "NO");
  }
  return 0;
}
