#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[30005];
ll b[30005];
ll ap[30005];
ll bp[30005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int brn1=0;
        int brn2=0;
        int brp1=0;
        int brp2=0;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            ap[a[i]]++;
            if(a[i]<0){
                brn1++;
            }
            else{
                brp1++;
            }
        }
        for(int i=1;i<=n;i++){
            cin>>b[i];
            if(b[i]<0){
                brn2++;
            }
            else{
                brp2++;
            }
            bp[b[i]]++;
        }
        if(ap[0]==n-1&&bp[0]==n-1){
            int l=0;
            int r=0;
            for(int i=1;i<=n;i++){
                if(a[i]!=0){
                    l=i;
                }
                if(b[i]!=0){
                    r=i;
                }
            }
            if(abs(l-r)%2==0){
                cout<<"NE"<<endl;
            }
            else{
                cout<<"DA"<<endl;
            }
        }
        else if(n==2){
            if(a[1]==-b[2]&&a[2]==-b[1]){
                cout<<"DA"<<endl;
            }
            else{
                cout<<"NE"<<endl;
            }
        }
        else{
            bool p=0;
            for(int i=1;i<=n;i++){
                if(ap[b[i]]==0&&ap[-b[i]]==0){
                    p=1;
                    cout<<"NE"<<endl;
                }
            }
            if(p==0){
                if((brn1%2!=brn2%2)||(brp1%2!=brp2%2)){
                    cout<<"NE"<<endl;
                }
                else{
                    cout<<"DA"<<endl;
                }
            }
        }
    }
    return 0;
}