#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    scanf("%i",&t);
    while(t--)
    {
        int n;
        scanf("%i",&n);
        int a[n+1],b[n+1];
        map<int,int>was1;
        map<int,int>was2;
        map<int,int>mapa1;
        map<int,int>mapa2;
        for(int i=1;i<=n;i++)
        {
            scanf("%i",&a[i]);
            mapa1[abs(a[i])]++;
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%i",&b[i]);
            mapa2[abs(b[i])]++;
        }
        int res=1;
        for(int i=1;i<=n;i++)
        {
            if(mapa1[abs(a[i])]==1) was1[abs(a[i])]=1;
            if(mapa1[abs(b[i])]==1) was2[abs(b[i])]=1;
            if(mapa1[abs(a[i])]!=mapa2[abs(a[i])])
            {
                res=0;
            }
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i]>0) mapa1[a[i]]--;
            if(b[i]>0) mapa2[b[i]]--;
        }
        for(int i=1;i<=n;i++)
        {
            if(abs(mapa1[abs(a[i])]-mapa2[abs(a[i])])%2==1 && was1[abs(a[i])]==0 && was2[abs(b[i])]==0)
            {
                res=0;
            }
        }
        if(res==0)
        {
            printf("NE ee\n");
            continue;
        }
        map<int,int>br1;
        map<int,int>Ia;
        map<int,int>ct;
        for(int i=1;i<=n;i++)
        {
            ct[abs(a[i])]++;
            int temp;
            if((i-ct[abs(a[i])])%2==0)
            {
                if(a[i]>0) temp=1;
                else temp=-1;
            }
            else
            {
                if(a[i]<0) temp=1;
                else temp=-1;
            }
            if(temp==1)
            {
                br1[abs(a[i])]++;
            }
            else
            {
                Ia[abs(a[i])]+=br1[abs(a[i])];
            }
        }
        /*for(int i=1;i<=n;i++)
        {
            printf("%i ",Ia[abs(a[i])]);
        }*/
        br1.clear();
        ct.clear();
        map<int,int>Ib;
        for(int i=1;i<=n;i++)
        {
            ct[abs(b[i])]++;
            int temp;
            if((i-ct[abs(b[i])])%2==0)
            {
                if(b[i]>0) temp=1;
                else temp=-1;
            }
            else
            {
                if(b[i]<0) temp=1;
                else temp=-1;
            }
            if(temp==1)
            {
                br1[abs(b[i])]++;
            }
            else
            {
                Ib[abs(b[i])]+=br1[abs(b[i])];
            }
        }
        /*printf("\n");
        for(int i=1;i<=n;i++)
        {
            printf("%i ",Ib[abs(a[i])]);
        }*/
        mapa1.clear();
        mapa2.clear();
        for(int i=1;i<=n;i++)
        {
            mapa1[abs(a[i])]++;
        }
        for(int i=1;i<=n;i++)
        {
            mapa2[abs(b[i])]++;
        }
        map<int,int>mapa3;
        map<int,int>mapa4;
        for(int i=1;i<=n;i++)
        {
            mapa3[abs(a[i])]=i;
            mapa4[abs(b[i])]=i;
        }
        for(int i=1;i<=n;i++)
        {
            if(mapa1[abs(a[i])]==1)
            {
                int temp=(abs(mapa3[abs(a[i])]-mapa4[abs(a[i])]))%2;
                if(temp==1 && a[i]==b[mapa4[abs(a[i])]])
                {
                    res=0;
                }
                if(temp==0 && a[i]!=b[mapa4[abs(a[i])]])
                {
                    res=0;
                }
            }
            else
            {
                if(abs(Ia[abs(a[i])]-Ib[abs(a[i])])%2==1)
                {
                    res=0;
                }
            }
        }
        if(res==0)
        {
            printf("NE\n");
            continue;
        }
        printf("DA\n");
    }
    return 0;
}