#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int tt;cin >> tt;
    for(int i = 0; i < tt; i++)
    {
        int n; cin >> n;
        int poz1,vr1,poz2,vr2;
        for(int j = 0; j < n;j++)
        {
            int x;cin >> x;
            if(x!=0)
            {
                poz1=j;
                vr1=x;
            }
        }
        for(int j = 0; j < n;j++)
        {
            int x;cin >> x;
            if(x!=0)
            {
                poz2=j;
                vr2=x;
            }
        }
        //cout << poz1 << vr1 << poz2 << vr2 << endl;
        if(abs(vr1) != abs(vr2))
        {
            cout << "NE" << endl;
            return;
        }
        if(abs(poz1-poz2)%2==0 && ((vr1<0 && vr2>0) || (vr2<0 && vr1>0)))
           cout << "NE" << endl;
        else if(abs(poz1-poz2)%2==0 && ((vr1>0 && vr2>0) || (vr2<0 && vr1<0)))
            cout << "DA" << endl;
        else if(abs(poz1-poz2)%2!=0 && ((vr1<0 && vr2>0) || (vr2<0 && vr1>0)))
            cout << "DA" << endl;
        else if(abs(poz1-poz2)%2!=0 && ((vr1<0 && vr2<0) || (vr2>0 && vr1>0)))
            cout << "NE" << endl;

    }
}

int main()
{
    solve();
    return 0;
}