#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

bool Mix(vector <int> a, vector<int> b,int e)
{
	if(a == b)return true;

	for (size_t i = e+1; i < a.size()-1; i++)
	{
		vector <int> t = a;
		swap(t[i], t[i + 1]);
		t[i] *= -1;
		t[i+1] *= -1;
		if (Mix(t, b,i))return true;
	}
	return false;
}

void NizMix()
{
	int t;

	scanf("%d",&t);
	
	vector<vector <int> > as;
	vector <vector <int> > bs;
	for (size_t i = 0; i < t; i++)
	{
		int n;
		scanf("%d", &n);
		
		vector <int> a(n,0);
		for (size_t j = 0; j < n; j++)
			scanf("%d", &a[j]);
		as.push_back(a);


		vector <int> b(n,0);
		for (size_t j = 0; j < n; j++)
			scanf("%d", &b[j]);
		bs.push_back(b);
	}
	cout << endl << endl << endl;
	for (size_t i = 0; i < t; i++)
	{
		if (Mix(as[i], bs[i],-1))printf("DA \n");
		else printf("NE \n");
	}
	
}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	NizMix();
	//Poklon();
	//kuvanje();


}