#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<int> a(n);
		vector<int> b(n);
		
		map<int, int> a_par_plus;
		map<int, int> a_par_minus;
		map<int, int> a_nepar_plus;
		map<int, int> a_nepar_minus;
		
		map<int, int> b_par_plus;
		map<int, int> b_par_minus;
		map<int, int> b_nepar_plus;
		map<int, int> b_nepar_minus;
		
		
		int p1 = 1;
		int p2 = 1;
		for(int i=0;i<n;i++){
			cin>>a[i];
			if(i%2==0){
				if(a[i]>0) a_par_plus[abs(a[i])]++;
				else a_par_minus[abs(a[i])]++;
			}
			else{
				if(a[i]>0) a_nepar_plus[abs(a[i])]++;
				else a_nepar_minus[abs(a[i])]++;
			}
		}
		for(int i=0;i<n;i++){
			cin>>b[i];
			if(i%2==0){
				if(b[i]>0) b_par_plus[abs(b[i])]++;
				else b_par_minus[abs(b[i])]++;
			}
			else{
				if(b[i]>0) b_nepar_plus[abs(b[i])]++;
				else b_nepar_minus[abs(b[i])]++;
			}
		}
		bool moze = true;
		
		for(int i=0;i<n;i++){
			if(a_par_plus[abs(a[i])]> (b_par_plus[abs(a[i])]+ b_nepar_minus[abs(a[i])] )) moze = false;
			if(a_nepar_plus[abs(a[i])]> (b_nepar_plus[abs(a[i])]+ b_par_minus[abs(a[i])] )) moze = false;
			if(a_par_minus[abs(a[i])]> (b_par_minus[abs(a[i])]+ b_nepar_plus[abs(a[i])] )) moze = false;
			if(a_nepar_minus[abs(a[i])]> (b_par_plus[abs(a[i])]+ b_nepar_minus[abs(a[i])] )) moze = false;
		}
		
		if(moze) cout<<"DA"<<endl;
		else cout<<"NE"<<endl;
	}
}