#include <iostream>

using namespace std;

const int MAXn = 30005;

void sortiraj(int* a, int* aa,int n){
    for(int i=0; i<n-1; i++)
        for(int j=0; j<n-1; j++){
            if(a[j]>a[j+1]){
                swap(a[j],a[j+1]);
                aa[j]++;
                aa[j+1]++;
            }
        }
}

void solve()
{
    int a[MAXn], b[MAXn], aa[MAXn]={0}, bb[MAXn]={0};
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]<0){
            a[i] = abs(a[i]);
            aa[i]+=1;
        }
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
        if(b[i]<0){
            b[i] = abs(b[i]);
            bb[i]+=1;
        }
    }
    sortiraj(a,aa,n);
    sortiraj(b,bb,n);
    for(int i=0; i<n; i++){
        if(aa[i]%2 != bb[i]%2){
            cout << "NE" << endl;
            return;
        }
    }
    cout << "DA";
}

int main()
{
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}