#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    int l=-1, r=-1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != 0) {
            l = i;
            break;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (b[i] != 0) {
            r = i;
            break;
        }
    }
    if (n == 1) {
        cout << "DA" << '\n';
        return;
    }
    if (l == -1 && r == -1) {
        cout << "DA" << '\n';
    }
    if (l == -1 || r == -1) {
        cout << "NE" << '\n';
    }
    if (abs(a[l]) == abs(b[r])) {
        if(abs(l-r)%2 == (a[l] == 0-b[r] ? 1 : 0)) {
            cout << "DA" << '\n';
        }
        else {
            cout << "NE" << '\n';
        }
    }
    else {
        cout << "NE" << '\n';
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}