#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;
    vector<int> cnt(1e9+1);
    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)];
    }
    bool ok = true;
    for(int i=1;i<=n;++i){
        if(!m.count(-a[i]) || abs(i-m[-a[i]]) % 2 == 0 || cnt[abs(a[i])]){ok = false;}
    }
    if(ok)cout<<"DA\n";
    else cout<<"NE\n";
}

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