#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, br = 0;
        cin >> n;
        vector<pair<int, bool>> a(n), b(n);

        for(int z = 0; z < n; z++){
            cin >> a[z].first;
            a[z].second = z%2;
        }
        for(int z = 0; z < n; z++){
            cin >> b[z].first;
            b[z].second = z%2;
        }

        for(int z = 0; z < n; z++){
            for(int j = 0; j < b.size(); j++){
                if((a[z].first == b[j].first && a[z].second == b[j].second) || (a[z].first == -b[j].first && a[z].second == !b[j].second)){
                    b.erase(b.begin()+j);
                    j = n;
                    br++;
                }
            }
        }

        if(br == n) cout << "DA" << endl;
        else cout << "NE" << endl;
    }
}