#include <iostream>

using namespace std;

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

    for (int i = 0; i < x; i++)
    {
        int n;
        cin >> n;
        if (n <= 1) {return 0;}
        int a[30000];
        int b[30000];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        for (int i = 0; i < n; i++)
        {
            cin >> b[i];
        }
        int brojac1 = 0;
        int brojac2 = 0;
        int p = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] == 0) {brojac1++;}
            if (b[i] == 0) {brojac2++;}
            if (a[i] != 0) {p = a[i];}
        }
        if (brojac1 == brojac2 && brojac1 == n-1)
        {
            for (int i = 0; i < n; i++)
            {
                if (b[i] == p || b[i] == -p)
                {
                    if (n == 2 && b[i] == p && a[i] == 0) {cout << "NE" << endl;}
                    else {cout << "DA" << endl;}
                }
            }
        }
        else
        {
            brojac1 = 0;
            brojac2 = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == -1) {brojac1++;}
                if (b[i] == -1) {brojac2++;}
            }
            int w = brojac1 - brojac2;
            if (w % 2 != 0) {cout << "NE" << endl;}
            else {cout << "DA" << endl;}
        }

    }
    return 0;
}