#include <bits/stdc++.h>
using namespace std;
long long n, t, a[30500], b[30500], x, y;
int main()
{
    scanf("%lld", &t);

    while(t--)
    {
        scanf("%lld", &n);
        for(int i = 1; i <= n; i++)
            scanf("%lld", &a[i]);
        for(int i = 1; i <= n; i++)
            scanf("%lld", &b[i]);
        for(int i = 1; i <= n; i++)
            if(a[i] != 0)
                x = i;
        for(int i = 1; i <= n; i++)
            if(b[i] != 0)
                y = i;
        if(((abs(x - y) % 2 == 1) and (a[x] * b[y] == -1)) or ((abs(x - y) % 2 == 0) and (a[x] * b[y] == 1)))
           cout << "DA" << endl;
        else
            cout << "NE" << endl;
    }


    return 0;
}