#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define ff(i,a,b) for(int (i) = (a);(i)<(b);(i)++)
#define fff(i,a,b) for(int (i) = (a);(i)<=(b);(i)++)

using namespace std;
using namespace __gnu_pbds;

int main()
{
    FAST;
    int x, y,in,jn;
    int t;
    cin>>t;
    ff(i,0,t){
        int n;
        cin>>n;
        ff(j,0,n){
            int a;
            cin>>a;
            if(a!=0){
                x= a;
                in = j;
            }
        }
        ff(j,0,n){
            int a;
            cin>>a;
            if(a!=0){
                y= a;
                jn = j;
            }

        }
        if((y== -x && abs(in-jn)%2 == 1)|| (y == x && abs(in-jn)%2 == 0)){
            cout<<"DA"<<endl;
        }else{
            cout<<"NE"<<endl;
        }
    }
    return 0;
}