#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    bool f=0;
    ll t;
    cin>>t;
    for(ll i=0;i<t;i++){
        ll n;
        cin>>n;
        ll a[n],b[n],ap,bp;
        for(ll j=0;j<n;j++){
            cin>>a[j];
            if(a[j]==0)
                f=1;
            if(a[j]!=0)
                ap=j;
        }
        for(ll j=0;j<n;j++){
            cin>>b[j];
            if(b[j]!=0)
                bp=j;
        }
        if(f==1){
            bool znaka=1,znakb=1;
            if(a[ap]<0)
                znaka=0;
            if(b[bp]<0)
                znakb=0;
            if(znaka==znakb){
                if(ap%2==bp%2){
                    cout<<"DA"<<endl;
                }
                else
                    cout<<"NE"<<endl;
            }
            else{
                if(ap%2!=bp%2)
                    cout<<"DA"<<endl;
                else
                    cout<<"NE"<<endl;
            }
        }

    }
}