#include <bits/stdc++.h>

using namespace std;

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

    int q;
    cin >> q;

    while(q--){
        int n;
        bool NULA = false;
        int index = 0,indexN = 0;
        cin >> n;
        vector<int> A(n);
        vector<int> B(n);

        for(int i = 0;i < n;i++) {
            cin >> A[i];
            if(A[i] == 0) NULA = true;
            if(A[i] == 1) index = i;
        }
        for(int i = 0;i < n;i++) {
            cin >> B[i];
            B[i] = abs(B[i]);
            if(B[i] == 1) indexN = i;
        }
        
        if((index - indexN) % 2 == 0) cout << "NE\n";
        else cout << "DA\n";
    }

    return 0;
}