#include <bits/stdc++.h>

using namespace std;
bool areEqual(int arr1[], int arr2[], int n)
{
    // If lengths of array are not equal means
    // array are not equal

    // Sort both arrays
    sort(arr1, arr1 + n);
    sort(arr2, arr2 + n);

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

    // If all elements were same.
    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] >= 0)
                va.push_back({abs(a[j]), {1, 1}});
            else if(j % 2 == 0 && a[j] < 0)
                va.push_back({abs(a[j]), {1, -1});
            else if(j % 2 == 1 && a[j] >= 0)
                va.push_back({abs(a[j]), {-1, 1});
            else
                va.push_back({abs(a[j]), {-1, -1});*/
            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] >= 0)
                vb.push_back({abs(b[j]), {1, 1}});
            else if(j % 2 == 0 && b[j] < 0)
                vb.push_back({abs(b[j]), {1, -1});
            else if(j % 2 == 1 && b[j] >= 0)
                vb.push_back({abs(b[j]), {-1, 1});
            else
                vb.push_back({abs(b[j]), {-1, -1});*/
            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;
}