#include<bits/stdc++.h>
using namespace std;

int a[30001];
int b[30001];

void babl(int a[], int n){
	//poredimo abs vrednost.
	bool sw = true;
	while(sw){
		bool pro = false;
		for(int i = 1; i < n; i++){
			if(abs(a[i]) < abs(a[i-1])){
				swap(a[i], a[i-1]);
				a[i] = -a[i];
				a[i-1] = -a[i-1];
				pro = true;
			}
		}
		if(pro == false)
			sw = false;
	}
}
//bubble sort oba niza??????" nakon bubble sort ukoliko imaju iste znakove svuda onda gg.
//koliko sam jak i dobar aloooo
void resi(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	babl(a, n);
	babl(b, n);
	bool moze = true;
	for(int i = 0; i < n; i++){
		if(a[i] != b[i]){
			moze = false;
			break;
		}
	}
	if(moze){
		cout << "DA" << "\n";
	}
	else cout << "NE" << "\n";
}


int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	while(t--) resi();
	return 0;
}