#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i ++)
#define mx 500005
#define LL long long
using namespace std;


int n;

int s[mx][2];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif

	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(0);

	int tc, a; cin >> tc;
	while(tc --){
		memset(s, 0, sizeof(s));
		cin >> n;
		for (int i = 0; i < n ; i ++) cin >> a, s[a][i % 2]++;
		int st = 0, id = 1, ok = 0;
		while (st < n) {
			if (s[id][0] + s[id][1] == 0) id ++;
			else if(s[id][st % 2]) s[id][st % 2] --, st ++;
			else {
				ok = 1;
				break;
			}
		}
		if (ok) cout << "NO" << endl;
		else cout << "YES" << endl;
	}

	return 0;
}

