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

int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t; cin >> t;
while (t--){
    ll n; cin >> n;
    ll a[n], b[n];
    ll poza;
    ll pozb;
    bool p = true;
    for( ll i = 0; i < n; i++ ){
        cin >> a[i];
        if ( a[i] != 0 ){
            poza = i;
        }
        else{
            p = false;
        }
    }
    for ( ll j = 0; j < n; j++ ){
        cin >> b[j];
        if ( b[j] != 0 ){
            pozb = j;
        }
        else{
            p = false;
        }
    }
    if ( p == true ){///drugi subtask
        ll s = 0;
            for ( int i = 0; i < n; i++ ){
                if ( a[i]+b[i] == 0 ){
                    s++;
                }
            }
        if (s%2 == 0){
            cout << "DA" << endl;
        }
        else{
            cout << "NE" << endl;
        }
    }
    else{///prvi subtask
        if ( abs(a[poza]) == abs(b[pozb]) ){
            if ( poza%2 == pozb%2 ){
                if (a[poza] + b[pozb] == 0){
                    cout << "NE" << endl;
                }
            else{
                cout << "DA" << endl;
            }
        }
        else{
            if ( a[poza] == b[pozb] ){
                cout << "NE" << endl;
            }
            else{
                cout << "DA" << endl;
            }
        }
    }
    else{
        cout << "NE"<< endl;
    }
}
}
return 0;
}