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

int n;
int a[30001], b[30001];

int sign(int x) {
    return x >= 0 ? 1 : -1;
}

namespace case1 { // sve nule, samo jedan broj
    void solve() {
        int A, B, i, j;

        for (int k = 0; k < n; k++)
        {
            if (a[k] != 0) {
                i = k;
                A = a[k];
            }
            if (b[k] != 0) {
                j = k;
                B = b[k];
            }
        }
        if (abs(A) != abs(B)) {
            cout << "NE\n";
            return;
        }

        if (sign(A) == sign(B)) {
            if (abs(i-j)&1) {
                cout << "NE\n";
                return;
            }
        } else {
            if ((abs(i-j)&1) == 0) {
                cout << "NE\n";
                return;
            }
        }

        cout << "DA\n";
        return;
    }
}


int main() {
    int t;
    cin >> t;
    while(t--) {
        cin >> n;
        int diffa = 0, diffb = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            diffa+= a[i] != 0;
        }
        for (int i = 0; i < n; i++)
        {
            cin >> b[i];
            diffb+= b[i] != 0;
        }

        if (diffa == 1 && diffb == 1) case1::solve();
    }
    return 0;
}