#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void f(){
    int n, br1 = 1, br2 = 0, br3 = 0, br4 = 0, a;
    cin >> n >> a;

    if(a != 0){
        for(int z = 1; z < n; z++){
            int b;
            cin >> b;
            if((b == a && z%2 == 0) || (b == -a && z%2 == 1)) br1++;
            else br2++;
        }
        for(int z = 0; z < n; z++){
            int b;
            cin >> b;
            if((b == a && z%2 == 0) || (b == -a && z%2 == 1)) br3++;
            else br4++;
        }

        if(br1 == br3 && br2 == br4) cout << "DA" << endl;
        else cout << "NE" << endl;
    }
    else{
        int c, z;
        for(int i = 0; i < n; i++){
            int b;
            cin >> b;
            if(b != 0){
                c = b;
                z = i;
            }
        }

        for(int i = 0; i < n; i++){
            int b;
            cin >> b;
            if(b != 0){
                if((b == c && i%2 == z%2) || (b == -c && i%2 == (z+1)%2)) cout << "DA" << endl;
                else cout << "NE" << endl;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

    for(int i = 0; i < t; i++){
        f();
    }
}