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

void solve(){
    cin>>n;
    ll b;
    map<ll,int> m;
    map<int,int> cnt;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        cnt[abs(a[i])]++;
    }
    for(int i=1;i<=n;++i){
        cin>>b;
        if(b)m[b] = i;
        cnt[abs(b)]--;
    }
    for(int i=1;i<=n;++i){
        if(!a[i])continue;
        if(cnt[abs(a[i])]){cout<<"NE\n"; return;}
        if((!m.count(-a[i]) || abs(i-m[-a[i]]) % 2 == 0) && (!m.count(a[i]) || abs(i-m[a[i]]) % 2 != 0)){cout<<"NE\n"; return;}
    }
    cout<<"DA\n";
}

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