#include <bits/stdc++.h>

using namespace std;

bool comp(int A,int B){
    return abs(A) <= abs(B);
}

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<long long> A(n);
        vector<long long> B(n);
        map<long long,long long> p1;
        map<long long,long long> p2;

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

        sort(A.begin(),A.end(),comp);
        sort(B.begin(),B.end(),comp);

        bool ans = false;

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

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

    return 0;
}