#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int q;
    cin >> q;

    while(q--){
        int n;
        cin >> n;
        vector<int> A(n);
        vector<int> B(n);
        map<int,int> p1;
        map<int,int> p2;

        for(int i = 0;i < n;i++) {
            cin >> A[i];
            p1[A[i]] = i;
        }
        for(int i = 0;i < n;i++) {
            cin >> B[i];
            B[i] = abs(B[i]);
            p2[B[i]] = i;
        }

        sort(A.begin(),A.begin());

        bool ans = false;

        for(int i = 0;i < n;i++){
            if(A[i] != 0){
                if(abs(p1[A[i]]-p2[A[i]]) % 2 == 0) {ans = true; break;}
            }
        }

        if(ans) cout << "NE\n";
        else cout << "DA\n";
    }

    return 0;
}