#include <iostream>

using namespace std;

int main()
{
    short int numberOfTasks;
    scanf("%hd",&numberOfTasks);
    
    for(int taskIndex=0; taskIndex<numberOfTasks; taskIndex++){
        short int n;
        bool test = true;
        scanf("%hd",&n);
        
        long int a[n];
        long int b[n];
        
        for(int i=0;i<n;i++){
            scanf("%li",&a[i]);
        }
        for(int i=0;i<n;i++){
            scanf("%li",&b[i]);
        }
        
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(a[i]==b[j])  if((i%2==0 && j%2!=0) || (i%2!=0 && j%2==0)){
                    test = false; 
                    break; 
                    break;
                }
                if(a[i]==-b[j]) if((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0)){
                    test = false; 
                    break; 
                    break;
                }
            }
        }
        
        
        if(test) printf("DA\n");
        else printf("NE\n");
    }
    
    return 0;
}