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

using namespace std;

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

    int t;
    cin >> t;

    for(int i = 0; i < t; i++){
        int n;
        bool k = true;
        cin >> n;
        vector<int> a(n), b(n);

        for(int z = 0; z < n; z++) cin >> a[z];
        for(int z = 0; z < n; z++) cin >> b[z];

        for(int z = 0; z < n; z++){
            for(int j = 0; j < n; j++){
                if((a[z] == b[j] && !(z%2 == j%2)) || (a[z] == -b[j] && !(z%2 == (j%2 + 1)%2))){
                    cout << "NE" << endl;
                    k = false;
                    j = n;
                    z = n;
                }
            }
        }

        if(k) cout << "DA" << endl;
    }
}