#include <bits/stdc++.h>
using namespace std;
struct numandpos
{
    int num;
    int pos;
};
bool comp(numandpos A, numandpos B)
{
    return A.num<B.num;
}
void stuff()
{
    bool dont_skip = 1;
    int n;
    cin >> n;
    string ans = "DA";
    vector <int> a;
    numandpos A[30001];
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        a.push_back(x);
        A[i].num=x;
        A[i].pos=i;
    }
    sort(A, A+n, comp);
    sort(a.begin(), a.end());
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        auto it = lower_bound(a.begin(), a.end(), -x);
        if (*it!=-x)
        {
            //nema -x u A
            it = lower_bound(a.begin(), a.end(), x);
            if (*it!=x)
            {
                //nema x u A
                ans = "NE";
                break;
            }
            else
            {
                //ima x u A
                int j = distance(a.begin(), it);
                if (abs(i-A[j].pos)%2==1)
                {
                    ans = "NE";
                    break;
                }
            }
        }
        else
        {
            //ima -x u A
            int j = distance(a.begin(), it);
            if (abs(i-A[j].pos)%2==0)
            {
                ans = "NE";
            }
        }
    }
    cout << ans << endl;
    }
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int b;
    cin >> b;
    for (int i=0; i<b; i++)
        stuff();
    return 0;
}