#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <climits>
#include <iterator>

#define IOS  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define SIGN(x) (((x)>0)-((x)<0))
#define FILL(a,x)   memset(a, (x), sizeof((a)));
#define cmp_db(a,b) (abs(b-a)<EPS)

using namespace std;

const long long MOD = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MAX_SIZE = 26;
const int dX[] = {-1, 1, 0, 0,-1, 1,-1, 1};
const int dY[] = { 0, 0,-1, 1, 1,-1,-1, 1};

template<class S, class T> ostream& operator<<(ostream& o,const pair<S,T>& a)  {o << a.first << " " << a.second <<" "; return o;}
template<class S, class T> ostream& operator<<(ostream& o,const map<S,T>& a)   { for (auto &it: a) o << (it); return o; }
template<class S> ostream& operator<<(ostream& o,const vector<S>& a)           { for (auto &it: a) o << (it) << " ";  o << "\n"; return o; }
template<class S> ostream& operator<<(ostream& o,const vector<vector<S> >& a)  { for (auto &it: a) o << (it); return o; }
template<class S> ostream& operator<<(ostream& o,const set<S>& a)              { for (auto &it: a) o << (it) << " "; o << "\n"; return o; }
const long long MAX = 1e5+10;

int main() {
    IOS;
    int t, n;
    bool flag;
    cin >> t;
    while(t--) {
        cin >> n;
        vector<int> a(n);
        map<int, int> index_parity[2];
        for(int i = 0; i < n; i++) {
            cin >> a[i];
            index_parity[i%2][a[i]]++;
        }
        sort(a.begin(), a.end());
        flag = true;
        for(int i = 0; i < n; i++) {
            if(index_parity[i%2][a[i]] == 0) {
                flag = false;
                break;
            }
            index_parity[i%2][a[i]]--;
        }
        if(flag) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return 0;
}