#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
using namespace std;
const int maxN = 30010;
ll a[maxN],b;
int n;

void solve(){
    cin>>n;
    unordered_map<ll,int> m;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i){
        cin>>b;
        if(b)m[b] = i;
    }
    bool ok = true;
    for(int i=1;i<=n;++i){
        if(m.count(-a[i]) && abs(i-m[-a[i]]) % 2 == 0){ok = false; break;}
    }
    if(ok)cout<<"DA\n";
    else cout<<"NE\n";
}

int main(void){
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}