#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int n;
        cin>>n;
        long ai,bi,a[n],b[n];
        for(int j=0;j<n;j++){
            cin>>a[j];
            if(a[j]!=0)ai=j;
        }
        for(int 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;
}