#include <bits/stdc++.h>

using namespace std;


bool provera (int a[], int b[], int n) {
    for (int i = 0; i < n; i++) {
        if (a[i] != (-1)*b[n-i-1]) {
            if (a[i] != b[i])
                return false;
        }
    }
    return true;
}

int main()
{
    int t;
    cin >> t;
    string resenja[t];

    for (int i = 0; i < t; i++) {
        int n;
        cin >> n;
        int a[n], b[n];
        for (int j = 0; j < n; j++) {
            cin >> a[j];
        }
        for (int j = 0; j < n; j++) {
            cin >> b[j];
        }
        resenja[i] = provera(a, b, n) ? "DA" : "NE";
    }

    for (int i = 0; i < t; i++) cout << resenja[i] << "\n";
    return 0;
}