#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	for (int i=0; i<t; i++)
	{
		int n;
		cin>>n;
		int a[n];
		int b[n];
		for (int j=0; j<n; j++)
		{
			cin>>a[j];
			
		}
		for (int j=0; j<n; j++)
		{
			cin>>b[j];
		}
		if (n==1)
		{
			if (a[0]==b[0])
			{
				cout<<"DA"<<endl;
			}
			else
			{
				cout<<"NE"<<endl;
			}
			continue;
		}
		if ((a[0]==0) || (a[1]==0))
		{
			int ka, kb;
			for (int j=0; j<n; j++)
			{
				if (a[j]!=0)
				{
					ka=j;
					break;
				}
			}
			for (int j=0; j<n; j++)
			{
				if (b[j]!=0)
				{
					kb=j;
					break;
				}
			}
			if (abs(a[ka])!=abs(b[kb]))
			{
				cout<<"NE"<<endl;
				break;
			}
			if ((a[ka]<0 && b[kb]<0) || (a[ka]>0 && b[kb]>0))
			{
				if (abs(ka-kb)%2==0)
				{
					cout<<"DA"<<endl;
				}
				else
				{
					cout<<"NE"<<endl;
				}
			}
			else
			{
				if (abs(ka-kb)%2==0)
				{
					cout<<"NE"<<endl;
				}
				else
				{
					cout<<"DA"<<endl;
				}
			}
		}
	}
}