#include <bits/stdc++.h>

using namespace std;

#define MAXN 30010

int main()
{
    long long t;
    cin>>t;
    for (long long z=0;z<t;z++)
    {
        long long n;
        cin>>n;
        vector<pair<long long,long long>> a;
        long long b[MAXN];
        for (long long i=1;i<=n;i++)
        {
            long long x;
            cin>>x;
            a.push_back({x,i%2});
        }
        for (long long i=1;i<=n;i++) cin>>b[i];
        sort(a.begin(),a.end());
        bool mark[MAXN]={false};
        for (long long i=1;i<=n;i++)
        {
            long long l1=0;
            long long r1=n-1;
            long long rez=-1;
            while (l1<=r1)
            {
                long long mid=(l1+r1)/2;
                if (a[mid].first>b[i]) r1=mid-1;
                else if (a[mid].first<b[i]) l1=mid+1;
                else if (a[mid].first==b[i])
                {
                    rez=mid;
                    break;
                }
            }
            if (rez!=-1)
            {
                long long l11=l1;
                long long r11=rez;
                while (l11<=r11)
                {
                    long long mid=(l11+r11)/2;
                    if (a[mid].first<b[i]) l11=mid+1;
                    else r11=mid-1;
                }
                long long l22=rez;
                long long r22=r1;
                while (l22<=r22)
                {
                    long long mid=(l22+r22)/2;
                    if (a[mid].first>b[i]) r22=mid-1;
                    else l22=mid+1;
                }
                if (i%2==0)
                {
                    if (a[l11].second==0) mark[i]=true;
                }
                else
                {
                    if (a[r11-1].second==1) mark[i]=true;
                }
            }
            l1=0;
            r1=n-1;
            rez=-1;
            while (l1<=r1)
            {
                long long mid=(l1+r1)/2;
                if (a[mid].first>b[i]*(-1)) r1=mid-1;
                else if (a[mid].first<b[i]*(-1)) l1=mid+1;
                else if (a[mid].first==b[i]*(-1))
                {
                    rez=mid;
                    break;
                }
            }
            if (rez!=-1)
            {
                long long l11=l1;
                long long r11=rez;
                while (l11<=r11)
                {
                    long long mid=(l11+r11)/2;
                    if (a[mid].first<b[i]*(-1)) l11=mid+1;
                    else r11=mid-1;
                }
                long long l22=rez;
                long long r22=r1;
                while (l22<=r22)
                {
                    long long mid=(l22+r22)/2;
                    if (a[mid].first>b[i]*(-1)) r22=mid-1;
                    else l22=mid+1;
                }
                if (i%2==0)
                {
                    if (a[l22].second==0) mark[i]=true;
                }
                else
                {
                    if (a[r22-1].second==1) mark[i]=true;
                }
            }
        }
        bool da=true;
        for (long long i=1;i<=n;i++)
        {
            if (mark[i]==false)
            {
                da=false;
                break;
            }
        }
        if (da) cout<<"DA"<<endl;
        else cout<<"NE"<<endl;
    }
}