#include "bits/stdc++.h"
using namespace std;

#define forn(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef double dbl;

const int MAX_N = 1e5 + 100;
int a[MAX_N], b[MAX_N];
map<int, int> cnt[2];

int main(){
#ifdef LOCAL
	assert(freopen("test.in", "r", stdin));
	assert(freopen("test.out", "w", stdout));
#endif

	int TestCnt;
	scanf("%d", &TestCnt);
	forn(testnum, TestCnt){
		forn(k, 2)
			cnt[k].clear();

		int N;
		scanf("%d", &N);
		forn(i, N)
			scanf("%d", &a[i]), b[i] = a[i];
		sort(b, b + N);
		forn(i, N)
			++cnt[i % 2][b[i]];

		bool ok = 1;
		forn(i, N){
			int &x = cnt[i % 2][a[i]];
			if(!x){
				ok = 0;
				break;
			}
			--x;
		}
		puts(ok ? "YES" : "NO");
	}
	
	return 0;
}
