#include <bits/stdc++.h>

struct test
{
	int N;
	std::vector<int> A, B;	
};

int main()
{
	int T;
	std::cin >> T;
	std::vector<test> tests(T);
	for(int i = 0; i < T; i++)
	{
		std::cin >> tests[i].N;
		for(int j = 0; j < tests[i].N; j++)
		{
			int x;
			std::cin >> x;
			tests[i].A.push_back(x);
		}
		
		for(int j = 0; j < tests[i].N; j++)
		{
			int x;
			std::cin >> x;
			tests[i].B.push_back(x);
		}
	}
	
	for(int i = 0; i < T; i++)
	{
		int ind1, ind2, z1, z2;
		const test& t = tests[i];
		
		for(int x = 0; x < t.N; x++)
		{
			int br = t.A[x];
			if(br != 0)
			{
				ind1 = x;
				z1 = br > 0 ? 1 : 0;
			}
			br = t.B[x];
			if(br != 0)
			{
				ind2 = x;
				z2 = br > 0 ? 1 : 0;
			}
		}
		
		if((ind1 == ind2 && z1 == z2) || 
		(ind1 % 2 == ind2 % 2 && z1 == z2) ||
		(ind1 % 2 != ind2 % 2 && z1 != z2))
			std::cout << "DA\n";
		else
			std::cout << "NE\n";
	}
	
	return 0;
}