#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstring>
#define INF 0x3f3f3f3f
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
const int N = 1e5 + 10;
int a[N], cnt[N][2];
void solve()
{
    memset(cnt, 0, sizeof(cnt));
    int n;
    cin >> n;
    for (int i = 1; i <= n;i++)
        cin >> a[i], cnt[a[i]][i & 1]++;
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n;i++)
        cnt[a[i]][i & 1]--;
    for (int i = 1; i < N;i++)
        if(cnt[i][1]||cnt[i][0])
        {
            cout << "NO" << endl;
            return;
        }
    cout << "YES" << endl;
}
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while(t--)
        solve();
    return 0;
}