#include <iostream>
//#include <fstream>
//#include <iomanip>
#include <cmath>
//#include <algorithm>
//#include <string>
//#include <vector>
//#include <utility>
//#include <map>
//#include <ctime>
//#include <cctype>
//#include <cstdlib>
//#include <limits>
//#include <numeric>
//#include <mycpp.h>

using namespace std;

string slucaj() {
	int n;
	cin >> n;
	int av, ai, an = 0, bv, bi, bn = 0, x;
	for(int i = 0; i < n; i++) {
		cin >> x;
		if(x != 0) {
			ai = i;
			av = x;
			an++;
		}
	}
	for(int i = 0; i < n; i++) {
		cin >> x;
		if(x != 0) {
			bi = i;
			bv = x;
			bn++;
		}
	}
	if(an == 0 && bn == 0) return "DA";
	if(an > 1 && bn > 1) return "NE";
	if(abs(av) != abs(bv)) return "NE";
	if((ai - bi) % 2 == 0 && (av > 0 && bv > 0 || av < 0 && bv < 0)) return "DA";
	if((ai - bi) % 2 != 0 && (av < 0 && bv > 0 || av > 0 && bv < 0)) return "DA";
	return "NE";
}

int main()
{
	int t;
	cin >> t;
	string res[t];
	for(int i = 0; i < t; i++)
		res[i] = slucaj();
	for(int i = 0; i < t; i++)
		cout << res[i] << endl;
	
}