#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

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

    int T;
    cin >> T;
    for(int p = 0; p < T; p++){
        bool d = true;
        vector<long long> A;
        vector<long long> B;
        vector<int> C;
        int N;
        long long int a, b;
        cin >> N;
        for(int i = 0; i < N; i++){
            C.push_back(-1);
        }
        for(int i = 0; i < N; i++){
            cin >> a;
            A.push_back(a);
        }
        for(int i = 0; i < N; i++){
            cin >> b;
            B.push_back(b);
        }
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(B[i] == A[j]){
                    if((j % 2) ==(i % 2)){
                        C[i] = 0;
                    }
                }
                else if(B[i] == -1 * (A[j])){
                    if((j % 2) != (i % 2)){
                        C[i] = 0;
                    }
                }
            }

        }
        for(int i = 0; i < N; i++){
            if(C[i] == -1){
                d = false;
            }
        }
        if(d) cout << "DA" << endl;
        else cout << "NE" << endl;

    }
}