#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        map<int, int> ma, mb;
		cin>>n;
		int a[n] , b[n];
		bool f=true;
		for(int i=0;i<n;i++)
        {
			cin>>a[i];
			if(i%2)
			ma[a[i]]++;
			b[i]=a[i];
		}
		sort(b,b+n);
		for(int i=0;i<n;i++)
		{
            if(i%2)
            mb[b[i]]++;
		}
		for(int i=0;i<n;i++)
        {
            if(ma[a[i]] != mb[a[i]])
            {
                f=false;
                break;
            }
        }
		if(f)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}
