#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
const int N = 30003;
ll a[N], b[N];


bool solve() {
    int n; cin >> n;
    map<ll, map<int, ll>> elementi;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        int indek = (i % 2 == 1);
        if (a[i] < 0)
            indek ^= 1;
        a[i] = abs(a[i]);

        elementi[a[i]][indek]++;
    }
    for (int i = 1; i <= n; i++) cin >> b[i];

    for (int i = 1; i <= n; i++) {
        int indek_b = (i % 2 == 1);
        if (b[i] < 0)
            indek_b ^= 1;
        b[i] = abs(b[i]);

        bool postoji = false;
        for (int j = 0; j <= 1 && !postoji; j++) {
            if (elementi[b[i]][j] == 0) continue;
            if (b[i] == 0 || indek_b == j) {
                postoji = true;
                elementi[b[i]][j]--;
            }
        }
        if (!postoji)
            return false;

    }
    return true;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int t=1; cin >> t;
    while (t--) {
        if (solve()) cout << "DA\n";
        else cout << "NE\n";
    }
}