#include <bits/stdc++.h>

using namespace std;

int main()
{
    int T;
    cin >> T;
    int N[T];
    for(int i = 0; i < T; i++){
        cin >> N[i];
        int A[N[i]];
        int B[N[i]];
        for(int j = 0; j < N[i]; j++){
            cin >> A[j];
        }
        for(int j = 0; j < N[i]; j++){
            cin >> B[j];
        }

        for(int j = 0; j < N[i]; j++){
            for(int v = 0; v < N[i]; v++){
                //cout << "A[" << j << "] = " << A[j] << " B[" << v << "] = " << B[v] << " ";
                if(A[j] != B[v] && A[j] + B[v] != 0){
                    break;
                }
                else if(A[j] == B[v] && j % 2 != v % 2){
                    cout << "NE" << endl;
                    break;
                }
                else if(A[j] != B[v] && j % 2 == v % 2){
                     cout << "NE" << endl;
                    break;
                }
                else
                     cout << "DA" << endl;
            }
        }
    }
}