#include <bits/stdc++.h>
#define lo long long
#define KKH "1546C"
#define fi first
#define se second
#define BIT(x,k) (((x)>>(k-1))&1)
#define rs(x,a) memset(x,(a),sizeof x)
#define off(x,k) ((x)^(1<<(k-1)))
using namespace std;
void START()
{
    #ifdef toilagun2004
    freopen(KKH".inp","r",stdin);
    freopen(KKH".out","w",stdout);
    #endif // toilagun2004
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const int gh=1e5+6;
int n,a[gh],g[gh],d[gh];
int main()
{
	START();
    int T;
    cin>>T;
    while(T--){
        cin>>n;
        rs(d,0);
        rs(g,0);
        for (int i=1;i<=n;i++)
        {
            cin>>a[i];
            if (i&1) d[a[i]]++;
            else g[a[i]]++;
        }
        sort(a+1,a+n+1);
        for (int i=1;i<=n;i++)
        {
            if (i&1) d[a[i]]--;
            else g[a[i]]--;
        }
        bool hung=true;
        for(int e=1;e<=100000 && hung;e++)
            if (d[e] || g[e]) hung=false;
        if (hung) cout<<"YES\n";
        else cout<<"NO\n";
    }
}