#include <bits/stdc++.h>

using namespace std;

typedef uint64_t ui;
typedef int64_t _i;
#define NL '\n'

ui a[2][50000];

bool check(ui n) {
	for (ui i = 0; i < n - 1; ++i) {
		//cout << a[i % 2][i / 2] << ' ' << a[(i + 1) % 2][(i + 1) / 2] << NL;

		if (a[i % 2][i / 2] > a[(i + 1) % 2][(i + 1) / 2]) {
			return false;
		}
	}

	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	ui ts;
	cin >> ts;

	ui n;

	while (ts--) {
		cin >> n;

		for (ui i = 0; i < n; ++i) {
			cin >> a[i % 2][i / 2];
		}

		sort(a[0], a[0] + ((n + 1) / 2));
		sort(a[1], a[1] + (n / 2));

		cout << (check(n) ? "YES" : "NO") << NL;
	}
	
	return 0;
}
