#include <bits/stdc++.h>
using namespace std;
int T, N; long long ai[30005], bi[30005];
int main(){
cin >> T;
for(int i=1; i<=T; i++){
    cin >> N;
    for(int j=1; j<=N; j++){
        cin>>ai[j];
    }
    for(int j=1; j<=N; j++){
        cin>>bi[j];
    }
    for(int j=1; j<=N-1; j++){
     if(ai[j] != bi[j] and ai[j+1] != bi[j+1] and abs(ai[j]) == abs(bi[j]) and abs(ai[j+1]) == abs(bi[j+1])){
        cout<<"NE"<<endl;
        break;
    }
    if(j == N-1){
        cout<<"DA"<<endl;
    }
    }
}
return 0;
}