#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
	
	int t;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>t;
	for (int test=0;test<t;test++){
		int n;
		cin>>n;
		vector<int> a(n),b(n);
		for (int i=0;i<n;i++){
			cin>>a[i];
		}
		for (int i=0;i<n;i++){
			cin>>b[i];
		}
		bool rez=true;
		for (int i=0;i<n;i++){
			for (int idot=0;idot<n;idot++){
				if (abs(a[i])==abs(b[i])){
					if (((abs(a[i])/a[i])==(abs(b[i])/b[i])) and (abs(i-idot)%2!=0)){
						rez=false;
					}
					if (((abs(a[i])/a[i])!=(abs(b[i])/b[i])) and (abs(i-idot)%2==0)){
						rez=false;
					}
				}
			}
		}
		if (rez==false) cout<<"NE\n";
		else cout<<"DA\n";
	}
	
	return 0;
}