#include <bits/stdc++.h>
using namespace std;
#define read_arr(arr, i)          \
    for (int l = 0; l < i; l++) { \
        cin >> arr[l];            \
    }
#define print_arr(arr, i)         \
    for (int l = 0; l < i; l++) { \
        cout << arr[l] << " ";    \
    }
#define rep(b) for (int i = 0; i < b; i++)
#define get_string(s) \
    string s;         \
    cin >> s;
typedef long long ll;
typedef unsigned long long ull;
int sum_of_digit(ull n) {
    string s = to_string(n);
    int sum = 0;
    for (int i = 0; i < s.length(); i++) sum += (s[i] - 48);
    return sum;
}
int sum_of_digit(string n) {
    int sum = 0;
    for (int i = 0; i < n.length(); i++) sum += (n[i] - 48);
    return sum;
}
int gcd(int a, int b) {
    return (!b) ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
}

int main() {
    fast();
    int t;cin>>t;
    while (t--)
    {
       int n;cin>>n;
       int arr[n],Max=-1,even[100000+5]={0},odd[100000+5]{0};
       for (int i = 0; i < n; i++)
       {
           cin>>arr[i];
           if(i%2==0)
           even[arr[i]]++;
           else
           odd[arr[i]]++;
           Max=max(Max,arr[i]);
       }
       sort(arr,arr+n);
       for (int i = 0; i < n; i++)
       {
           if(i%2==0)
           even[arr[i]]--;
           else
           odd[arr[i]]--;
       }
       
       for (int i = 0; i <=Max; i++){
           if(!(even[i]==0&&odd[i]==0))
           {
               cout<<"NO"<<endl;
               goto y;
           }
       }
       cout<<"YES"<<endl;
       y:;
    }
}