#include <bits/stdc++.h>

using namespace std;
bool areEqual(int arr1[], int arr2[], int n)
{



    sort(arr1, arr1 + n);
    sort(arr2, arr2 + n);


    for (int i = 0; i < n; i++)
        if (arr1[i] != arr2[i])
            return false;

 
    return true;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++)
    {
        long long int n;
        cin >> n;
        int a[n+5], b[n+5];
        vector<pair<int, pair<int, int>>> va;
        vector<pair<int, pair<int, int>>> vb;
        for(int j = 0; j < n; j++)
        {
            cin >> a[j];

            if(j % 2 != 0)
                a[j] = a[j] * (-1);
        }
        for(int j = 0; j < n; j++)
        {
            cin >> b[j];

            if(j % 2 != 0)
                b[j] = b[j] * (-1);

        }
        auto ans = areEqual(a, b, n);
        if(ans)
            cout << "DA" << endl;
        else
            cout << "NE" << endl;
    }
    return 0;
}