#include<bits/stdc++.h>

using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<int>v(n);
		map<int, pair<int, int>>m, m1;
		for (int i = 0; i < n; i++) {
			cin >> v[i];
			if (i % 2) m[v[i]].first++;
			else m[v[i]].second++;
		}
		sort(v.begin(), v.end());

		for (int i = 0; i < n; i++) {
			if (i % 2) m1[v[i]].first++;
			else m1[v[i]].second++;
		}
		int flag = 0;
		vector<pair<int, int>>v1, v2;
		for (auto i : m)
			v1.push_back({i.second.first, i.second.second});
		for (auto i : m1)
			v2.push_back({i.second.first, i.second.second});
		n = v1.size();
		for (int i = 0; i < n; i++)
		{
			if ((v1[i].first != v2[i].first) || (v1[i].second != v2[i].second))
			{
				cout << "NO" << endl;
				flag = 1; break;
			}
		}

		if (!flag) cout << "YES" << endl;
	}
}