#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> aa;
        vector <int> b;

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

    return 0;
}