#include <bits/stdc++.h>

using namespace std;

int main()
{
    int numberOfTasks;
    cin >> numberOfTasks;
    
    for(int taskIndex=0; taskIndex<numberOfTasks; taskIndex++){
        int n;
        bool test = true;
        cin >> n;
        
        long int a[n];
        long int b[n];
        
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        for(int i=0;i<n;i++){
            cin >> 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) cout << "DA";
        else cout << "NE";
    }
    
    return 0;
}