#include <bits/stdc++.h>
#define ll long long

using namespace std;

//const ll MAX_N = 1e9+1;

void solve() {
    int n;
    cin >> n;

    vector<ll> a(n+1), b(n+1);

    //vector<ll> raz(MAX_N);
    map<ll, ll> raz;

    for(int i=1; i<=n; i++) {
        cin >> a[i];
        raz[abs(a[i])] = i;
    }

    ll ok = 0;
    for(int i=1; i<=n; i++) {
        bool ok1 = false;
        cin >> b[i];
        if(b[i] == - a[raz[abs(b[i])]]) ok1 = true;

        raz[abs(b[i])] =  abs(raz[abs(b[i])] - i);
        if((raz[abs(b[i])] % 2) && ok1) ok++;
        if((raz[abs(b[i])] % 2 == 0) && !ok1) ok++;
    }

    if(ok == n) cout << "DA\n";
    else cout << "NE\n";

    return;
}

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

    int t;
    cin >> t;

    while(t--) {
            solve();
    }

    return 0;
}