#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;

    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;
}

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

    int t;
    cin >> t;

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