#include <bits/stdc++.h>

using namespace std;

int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> v(n);
        vector<int> e,o;
        for(int i = 0; i < n; i++){
            cin >> v[i];
            if(i%2 == 0){
                e.push_back(v[i]);
            }
            else{
                o.push_back(v[i]);
            }
        }
        vector<int> c;
        sort(e.begin(),e.end());
        sort(o.begin(),o.end());
        int a = 0;
        int b = 0;
        for(int i = 0; i < n; i++){
            if(i%2 == 0){
                c.push_back(e[a]);
                a++;
            }
            else{
                c.push_back(o[b]);
                b++;
            }
        }
        if(is_sorted(c.begin(),c.end())){
            cout << "YES\n";
        }
        else{
            cout << "NO\n";
        }
    }
}