#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
const int modulo = 998244353;

#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cout << vars << " = ";
string delim = "";
(..., (cout << delim << values, delim = ", "));
}

typedef unsigned long long int  ull;
typedef long long int ll;

ll power(ll a, ll b)
{
    ll ans = 1;
    while(b != 0)
    {
        if((b % 2) == 0)
        {
            a = ((a % mod) * (a % mod)) % mod;
            b /= 2;
        }
        else
        {
            ans = ((ans % mod) * (a % mod)) % mod;
            b--;
        }
    }
    return (ans % mod);
}

void read_input_from_file()
{
    #ifndef ONLINE_JUDGE
    freopen("input_file.txt","r",stdin);
    freopen("output_file.txt","w",stdout);
    #endif
}

void shivam()
{
    int n;
    cin>>n;
    int arr[n + 1];
    int ans[n + 1];
    vector<int> even_arr;
    vector<int> odd_arr;
    vector<int> even_ans;
    vector<int> odd_ans;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        ans[i] = arr[i];
    }
    sort(ans + 1 , ans + n + 1);
    for(int i=1;i<=n;i++)
    {       
        if(i % 2 == 0) // even
        {
            even_arr.push_back(arr[i]);
            even_ans.push_back(ans[i]);
        }
        else // odd
        {
            odd_arr.push_back(arr[i]);
            odd_ans.push_back(ans[i]);
        }
    }
    sort(even_arr.begin() , even_arr.end());
    sort(even_ans.begin() , even_ans.end());
    sort(odd_arr.begin() , odd_arr.end());
    sort(odd_ans.begin() , odd_ans.end());
    if((even_arr.size() == even_ans.size()) && (odd_arr.size() == odd_ans.size()))
    {
        for(int i=0;i<even_arr.size();i++)
        {
            if(even_arr[i] != even_ans[i])
            {
                cout<<"NO\n";
                return;
            }
        }
        for(int i=0;i<odd_arr.size();i++)
        {
            if(odd_arr[i] != odd_ans[i])
            {
                cout<<"NO\n";
                return;
            }
        }
    }
    else
    {
        cout<<"NO\n";
        return;
    }
    cout<<"YES\n";
    return;
}

int main()
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // read_input_from_file();
    ll t = 1;
    cin>>t;
    for(ll i=1;i<=t;i++)
    {
        shivam();
    }
    auto end = std::chrono::high_resolution_clock::now();
    //cout <<"\nExecution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds "<<"\n";
    return 0;
}