#include <bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	int temp = t;
	string c[t];
	int j = 0;
	while(t--){
		int n; cin >> n;
		long long a[n];
		long long b[n];
		map<long long, vector<long long>> mapa;
		for(int i = 0; i < n; i++){
			cin >> a[i];
			mapa[abs(a[i])].push_back(i);
		}
		for(int i = 0; i < n; i++){
			cin >> b[i];
			mapa[abs(b[i])].push_back(i);
		}
		bool moze = true;
		for(int i = 0; i < n; i++){
			if(abs(mapa[abs(a[i])][0] - mapa[abs(a[i])][1]) % 2 == 1){
				if(a[mapa[abs(a[i])][0]] == b[mapa[abs(a[i])][1]])
					moze = false;
			}
			else{
				if(a[mapa[abs(a[i])][0]] != b[mapa[abs(a[i])][1]])
					moze = false;
			}
		}
		if(moze) c[j] = "DA";
		else c[j] = "NE";
		j++;
	}
	for(int k = 0; k < temp; k++){
		cout<<c[k]<<endl;
	}
}