#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    for(int y=0;y<t;y++){
        int n;
        cin>>n;
        int a[n];
        int b[n];
        int brojminusevaa=0;
        int brojminusevab=0;
        for(int z=0;z<n;z++){
            cin>>a[z];
            if (a[z]<0)
                brojminusevaa++;
        }
        for(int z=0;z<n;z++){
            cin>>b[z];
            if (b[z]<0)
                brojminusevab++;
        }
        int i=0;
        int j=0;
            while((j<n)&&(i<n)){
                if(((a[i]==b[j])&&((i+j)%2==0))or ((a[i]==-b[j])&&((i+j)%2==1))){
                    i++;
                    j=0;
                }
                else
                {
                    j++;
                }
            }
        }
        if(i==n){
            cout<<"DA"<<endl;
        }
        else{
            cout<<"NE"<<endl;
        }
    return 0;
}