﻿#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 2;

int g[N][2];
int n;
int a[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int T;
	scanf("%d", &T);
	while (T--) {
		bool ok = true;
		scanf("%d", &n);
		for (int i = 1; i <= n; ++i) {
			scanf("%d", &a[i]);
			g[a[i]][i & 1]++;
		}
		sort(a + 1, a + 1 + n);
		for (int i = 1; i <= n; ++i) {
			int idx1 = lower_bound(a + 1, a + 1 + n, a[i]) - a;
			int idx2 = upper_bound(a + 1, a + 1 + n, a[i]) - a - 1;
			int len = idx2 - idx1 + 1, odd, even;
			if (len & 1) {
				if (idx1 & 1) {
					odd = len / 2 + 1;
					even = len / 2;
				}
				else {
					even = len / 2 + 1;
					odd = len / 2;
				}
			}
			else {
				odd = even = len / 2;
			}
			if (even != g[a[i]][0] || odd != g[a[i]][1]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		for (int i = 1; i <= n; ++i) g[a[i]][0] = g[a[i]][1] = 0;
	}
}