#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{

    int T;
    cin >> T;
    int N;
    int nule=0;
    int jedinice =0;
    int negA=0 , negB=0;
    int elA, elB;
    vector<bool> odg(T);
    for(int i=0;i<T;i++)
    {
        cin >> N;
        vector<int> Ai(N);
        vector<int> Bi(N);
        for(int i=0; i<N; i++)
            cin >> Ai[i];
        for(int i=0; i<N; i++)
            cin >> Bi[i];
        if(N==2){
        if(abs(Ai[0]) == abs(Bi[1]))
            odg[i]=1;
        }
        for(int j=0;j<N;j++){
            if(Ai[j]==0)
                nule++;
            if(Bi[j]==0)
                nule++;
            if(abs(Ai[j])==1)
                jedinice++;
            if(abs(Bi[j])==1)
                jedinice++;
            if(Ai[j]==-1)
                negA++;
            if(Bi[j]==-1)
                negB++;
            if(Ai[j]!=0)
                elA=Ai[j];
            if(Bi[j]!=0)
                elB=Bi[j];
            }

        if(nule== Ai.size()+Bi.size()-2)
        {
            if(abs(elA)==abs(elB))
                odg[i]=1;
            else
                odg[i]=0;
        }

        if(jedinice == Ai.size()+Bi.size()){
            if(abs(negA-negB)%2==1)
                odg[i]=0;
            else
                odg[i]=1;
        }
        jedinice=0;
        nule=0;
        negA=0;
        negB=0;
        elA=0;
        elB=0;

    }
    for(int i=0;i<T;i++){
        if(odg[i])
            cout << "DA" << endl;
        else
            cout << "NE" << endl;
    }

    return 0;
}