#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int> v(n);
        for (int i=0;i<n;i++) cin>>v[i];
        map<int,unordered_set<int>> m;
        for (int i=0;i<n;i++) m[v[i]].insert(i);
        sort(v.begin(),v.end());
        int flag=0;
        for (int i=0;i<n;i++)
        {
            int temp;
            for (auto it:m[v[i]])
            {
                temp=abs(it-i);
                if (temp%2==0) {flag=1;m[v[i]].erase(it);break;}
                else flag=0;
            }
            if (flag==0) break;
        }
        if (flag==1) cout<<"YES\n";
        else cout<<"NO\n";
    }
}