#include <bits/stdc++.h>


using namespace std;

int main(){










long long int n;
    cin >>n;
    vector <string> k;
    for(long long int i = 0;i<n;i++){
        long long int a;
        cin >>a;
        vector <long long int> v1;
        vector <long long int> v2;
        vector <pair<bool,bool>> v3;
        vector <pair<bool,bool>> v4;
        vector <bool> v5;


        for(long long int j = 0;j<a;j++){
            long long int b;
            cin>>b;


            v1.push_back(b);

            }
         long long int maxi = v1[0];
        for(long long int j = 1;j<a;j++){
            if(abs(v1[j])>maxi){
                maxi  = abs(v1[j]);
            }
        }

        for(long long int j = 0;j<=maxi;j++){
            v3.push_back(make_pair(false,false));
            v4.push_back(make_pair(false,false));
        }

        for(long long int j = 0;j<a;j++){
            long long int c;
            cin>>c;

            v2.push_back(c);

        }
        for(long long int j = 0;j<a;j++){
            if(v1[j]>0){
                if(j%2 == 0){
                    v3[abs(v1[j])].first = false;
                    v3[abs(v1[j])].second = true;
                }
                else{
                    v3[abs(v1[j])].first = false;
                    v3[abs(v1[j])].second = false;
                }
            }
            else if(v1[j]<0){
                if(j%2 == 0){
                    v3[abs(v1[j])].first = true;
                    v3[abs(v1[j])].second = true;
                }
                else{
                    v3[abs(v1[j])].first = true;
                    v3[abs(v1[j])].second = false;
                }
            }
            else{
                v3[0].first=false;
                v3[0].second= false;
            }
            if(v2[j]>0){
                if(j%2 == 0){
                    v4[abs(v2[j])].first = false;
                    v4[abs(v2[j])].second = true;
                }
                else{
                    v4[abs(v2[j])].first = false;
                    v4[abs(v2[j])].second = false;
                }
            }
            else if(v2[j]<0){
                if(j%2 == 0){
                    v4[abs(v2[j])].first = true;
                    v4[abs(v2[j])].second = true;
                }
                else{
                    v4[abs(v2[j])].first = true;
                    v4[abs(v2[j])].second = false;
                }
            }
            else{
                v4[0].first=false;
                v4[0].second= false;
            }


        }

        bool ita = true;

        for(long long int i = 0;i<=maxi && ita == true;i++){
                v5.push_back(false);

            if((v3[i].first == v4[i].first &&v3[i].second == v4[i].second) || (v3[i].first == !v4[i].first &&v3[i].second == !v4[i].second)){
                v5[i] = true;
                //cout<<"d";
            }
            else{
                ita = false;
               k.push_back("NE");
            }
            if(v5[i] ==true && i==maxi){
                k.push_back("DA");
            }
        }

        }
        for(long long int i = 0;i<n;i++){

            cout<<k[i]<<endl;
        }






    }