#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    long long t;
    cin>>t;
    for(long long i=0;i<t;i++){
        long long n;
        cin>>n;
        long long ai,bi,a[n],b[n];
        for(long long j=0;j<n;j++){
            cin>>a[j];
            if(a[j]!=0)ai=j;
        }
        for(long long j=0;j<n;j++){
            cin>>b[j];
            if(b[j]!=0)bi=j;
        }
        if(abs(a[ai])==abs(b[bi])){
            if((ai-bi)%2==0){
                if(a[ai]!=b[bi])cout<<"NE"<<"\n";
                else cout<<"DA"<<"\n";
            }
            else{
                if(a[ai]==b[bi])cout<<"NE"<<"\n";
                else cout<<"DA"<<"\n";
            }
        }
        else cout<<"NE"<<"\n";
    }
    return 0;
}