#include <bits/stdc++.h>

using namespace std;

vector<int> arrayswap(int j, int i, vector<int> a){
    int k = a[j];
    for (int r = j; r < i; r++)
        a[r] = 0 - a[r + 1];
    if ((i - j) % 2 == 0) a[i] = k;
    else a[i] = 0 - k;
    return a;
}


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

    int t;
    cin >> t;
    for (int i = 0; i < t; i++){

        int n, k;
        cin >> n;
        vector <int> a;
        vector <int> b;
        for (int i = 0; i < n; i++){
            cin >> k;
            a.push_back(k);
        }
        for (int i = 0; i < n; i++){
            cin >> k;
            b.push_back(k);
        }
        bool sol = true;
        for (int i = n - 1; i >= 0; i--){
                for (int j = 0; j < n; j++){
                    if (abs(a[j]) == abs(b[i])) {
                        a = arrayswap(j, i, a);
                        break;
                    }
                    }
                if (a[i] != b[i]){
                    cout << "NE\n";
                    sol = false;
                    break;
                }
            }
        if (sol) cout << "DA\n";

    }
    return 0;
}