#include <iostream>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
    ll t;
    cin>>t;
    for(ll i=0;i<t;i++){
        ll n;
        cin>>n;
        ll a[n],b[n],sa=0,sb=0,absa=0,absb=0;
        for(ll j=0;j<n;j++){
            cin>>a[j];
            sa=sa+a[j];
            absa=absa+abs(a[j]);
        }

        for(ll j=0;j<n;j++){
            cin>>b[j];
            sb=sb+b[j];
            absb=absb+abs(b[j]);
        }
        if(abs(sa)%2!=abs(sb)%2 || absa!=absb)
            cout<<"NE"<<endl;
        else{
            bool f=0,znaka=1,znakb=1;
            ll ap,bp;
            for(ll j=0;j<n;j++){
                if(a[j]==0)
                    f=1;
                else{
                    ap=j;
                    if(a[j]<0)
                        znaka=0;
                }
            }
            for(ll j=0;j<n;j++){
                if(b[j]!=0){
                    bp=j;
                    if(b[j]<0)
                        znakb=0;
                }
            }

            if(f==1){
                if(znaka==znakb){
                    if(ap%2==bp%2)
                        cout<<"DA"<<endl;
                    else
                        cout<<"NE"<<endl;
                }
                else{
                    if(ap%2==bp%2)
                        cout<<"NE"<<endl;
                    else
                        cout<<"DA"<<endl;
                }
            }
            else if(f==0){
                ll br=0,para=0,parb=0;
                ll nepara=0,neparb=0;
                for(ll j=0;j<n;j++){
                    if(j%2==0){
                        para=para+a[j];
                        parb=parb+b[j];
                    }
                    if(a[j]!=b[j])
                        br++;
                }
                nepara=sa-para;
                neparb=sb-parb;
                if(br%2==0 && abs(abs(para)-abs(nepara))==abs(abs(parb)-abs(neparb)))
                    cout<<"DA"<<endl;
                else
                    cout<<"NE"<<endl;
            }
        }
    }
}