#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

void solve(){
	ll n;
	cin>>n;
	vector <ll> a(n),b(n);
	bool f=false;
	ll k=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=1;i<n;i++){
		swap(a[i-1],a[i]);	
		a[i-1]=-a[i-1];
		a[i]=-a[i];
		if(a==b){
			f=true;
			break;
		}
 	}
 	if(f)cout<<"DA\n";
 	else cout<<"NE\n";
}

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