#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    while(t>0)
    {
        long long int n,pa=0,la=0,pb=0,lb=0;
        cin >> n;
        long long int a[n],b[n];
        for(long long int i =0;i<n;i++)
            {cin >> a[i];
            if(a[i]!=0)
            {
                pa = a[i];
                la=i;
            }
            }
        for(long long int i =0;i<n;i++)
            {cin >> b[i];
            if(b[i]!=0)
            {
                pb = b[i];
                lb=i;
            }
            }

        if(pa == pb && la == lb || pa*(-1) == pb && la != lb|| n>2)
            cout << "DA" << endl;
        else
            cout << "NE" << endl;
        t--;
    }



    return 0;
}