#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<unordered_map>
#include<map>
#include<unordered_set>
#include<algorithm>
#include<queue>
#include<utility>
#include<string>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF 1000000007
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int>a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		vector<int>b=a;
		sort(b.begin(), b.end());
		map<int, int>dp1;
		map<int, int>dp2;
		for (int i = 0; i < n; i++) {
			dp1[a[i]] += i % 2;
			dp2[b[i]] += i % 2;
		}
		bool ok = 1;
		for (int i = 0; i < n; i++) {
			if (dp1[a[i]] != dp2[a[i]]) {
				ok = 0;
				break;
			}
		}
		if (ok) {
			cout << "YES\n";
		}
		else cout << "NO\n";
	}
	cin.ignore(2);
	return 0;
}