#include <bits/stdc++.h>
typedef long long ll;
using namespace std;


void dbg(ll a[1000], ll n)
{
    for(int i=0;i<n;++i)
    {
        cout << a[i] << " ";
    }
    cout << "\n";

}
void solve()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;++i)
    {
        cin >> b[i];

    }
    bool ok= false;
    int dist;
    for(int i=0;i<n;++i)
    {
        if(b[i] < 0) {
            for(int j=0;j<n;++j)
            {
                if(abs(b[i]) == abs(a[j]))
                {
                    dist = abs(j-i);
                    if(a[j] > 0 && dist%2!=1 && !ok)
                    {
                        break;
                    }
                    else if(a[j] < 0 && dist%2!=0 && !ok)
                    {
                        break;
                    }
                    else
                    {
                        ok = true;
                    }
                }
            }
        }
        else
        {
            for(int j=0;j<n;++j)
            {
                if(abs(b[i]) == abs(a[j]))
                {
                    dist = abs(j-i);
                    if(a[j] > 0 && dist%2!=0 && !ok)
                    {
                        break;
                    }
                    else if(a[j] < 0 && dist%2!=1 && !ok)
                    {
                        break;
                    }
                    else
                    {
                        ok = true;
                    }
                }
            }

        }
    }
    ok? cout << "DA" << "\n" : cout << "NE" << "\n";




}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int t;
    cin >> t;
    while(t--)
    {
        solve();
    }







}