#include <iostream>

using namespace std;

int main()
{
	int t, n;
	cin >> t;
	
	long long a[n], b[n];
	long long res[t];
	for(int i = 0; i < t; i++)
		res[i] = 0;
	
	int q = 0;
	
	for (int k = 0; k < t; k++){
		cin >> n;
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int j = 0; j < n; j++)
			cin >> b[j];
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (a[i] != 0 && b[j] != 0){
					if (a[i] == b[j]){
						if ((i%2!= 0 && j%2 != 0) || (i%2 == 0 && j%2 == 0)){
							res[q] = 1; 
							++q; 
							break; //cout << "DA" << endl;
						}	
						else ++q; //cout << "NE" << endl;
					}
					else {
						if (a[i]*-1 == b[j]){
							if (i == 0 || i == n-1){
								if (j%2 != 0){
									res[q] = 1;
									++q;
									break; //cout << "DA" << endl;
								}
								else {
									res[q] = 0;
									++q;
								} //cout << "NE" << endl;
							}
						
							else {
								if (j%2==0){
									res[q] = 1;
									++q;
									break; //cout << "DA" << endl;
								}	
								else ++q; //cout << "NE" << endl;
							}
						}
						else ++q; //cout << "NE" << endl;
					}
				}	
			}
		}
	}
	
	for (int i = 0; i < t; i++){
		if (res[i] == 1)
			cout << "DA" << endl;
		else cout << "NE" << endl;
	}
	
	return 0;
}