#include<bits/stdc++.h>

using namespace std;
int A[11][30030], B[11][30030];
 pair <int, int> pom[11][30030];

int main(){
   int Q; cin >> Q;
   int N[11];
   string R[11];
   int i, j, l, m;
   for(j = 0; j < Q; j++){
    cin >> N[j];
    for(i = 0; i < N[j]; i++){
        cin >> A[j][i];
    }
    for(i = 0; i < N[j]; i++){
        cin >> B[j][i];
        pom[j][i] = make_pair(abs(B[j][i]),i);
    }

   }
   for(i = 0; i < Q; i++){
    sort(pom[i], pom[i] + N[i]);
   }
    int pos;
    bool flag = true, flag1;

    for(i = 0; i < Q;i++){
        flag = true;
        for(j = 0; j < N[i]; j++){
            int a = 0, b = N[i], c;
            flag1 = false;
            int k = abs(A[i][j]);
            while(a + 1 < b){
                c = (a + b)/2;
                if(pom[i][c].first == k){
                    pos = pom[i][c].second;
                    a = b;
                    flag1 = true;
                } else if(pom[i][c].first > k) b = c;
                else a = c;
            }
            if(pom[i][b].first == k) pos = pom[i][b].second;
            else if(pom[i][a].first == k) pos = pom[i][a].second;
            else if(!flag1){
                R[i] = "NE";
                j = N[i];
                flag = false;
                continue;
            }
            if((pos - j)%2 == 0){
                if(A[i][j] == -B[i][pos]){
                    R[i] = "NE";
                    flag = false;
                }
            }else {
                if(A[i][j] == B[i][pos]){
                    R[i] = "NE";
                    flag = false;
                }
            }
        }
        if(flag) R[i] = "DA";
    }
    for(i = 0; i < Q; i++){
        cout << R[i] << endl;
    }
}