#include <iostream>
//#include <fstream>
//#include <iomanip>
#include <cmath>
//#include <algorithm>
//#include <string>
#include <vector>
#include <utility>
#include <map>
//#include <ctime>
//#include <cctype>
//#include <cstdlib>
//#include <limits>
//#include <numeric>
//#include <mycpp.h>

using namespace std;
typedef long long ll;

struct Element {
	ll vrednost;
	int index;
	char znak;
};

bool Moze(Element a, Element b) {
	return (
		(a.vrednost == b.vrednost) &&
		(
			(((a.index - b.index)) % 2 == 0 && (a.znak == '+' && b.znak == '+' || a.znak == '-' && b.znak == '-')) ||
			(((a.index - b.index)) % 2 != 0 && (a.znak == '-' && b.znak == '+' || a.znak == '+' && b.znak == '-'))
		)
	);
}

string slucaj() {
	int n;
	cin >> n;
	map<ll,ll> hash;
	map<ll, vector<Element> > A, B;
	vector<ll> keys;
	ll a[n], b[n];
	bool ne = false;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(A.find((ll)abs(a[i])) == A.end()) {
			vector<Element> v;
			keys.push_back((ll)abs(a[i]));
			A.insert(pair<ll, vector<Element> >((ll)abs(a[i]), v));
		}
		Element e;
		e.vrednost = (ll)abs(a[i]);
		e.index = i;
		e.znak = a[i] < 0 ? '-' : '+';
		A.at((ll)abs(a[i])).push_back(e);
		if(hash.find((ll)abs(a[i])) == hash.end()) hash.insert(pair<ll,ll>((ll)abs(a[i]), 0));
		hash.at((ll)abs(a[i]))++;
	}
	
	
	for(int i = 0; i < n; i++) {
		cin >> b[i];
		
		if(!ne) {
			Element e;
			e.vrednost = (ll)abs(b[i]);
			e.index = i;
			e.znak = b[i] < 0 ? '-' : '+';
			for(int k = 0; k < keys.size(); k++) {
				ll key = keys[k];
				if(key != (ll)abs(b[i])) continue;
				//cout << key << endl;
				vector<Element> el = A.at(key);
				//cout << "el" << endl;
				//for(int w = 0; w < el.size(); w++) cout << el[w].index << "\t";
				//cout << endl;
				for(int j = el.size() - 1; j >= 0; j--) {
					if(Moze(el[j], e)) {
						el.erase(el.begin() + j);
						continue;
					}
					else {
						//cout << "NE moze " << b[i] << " A" << endl;
						ne = true;
						break;
					}
				}
			}
		}
	
		if(!ne) {
			if(hash.find((ll)abs(b[i])) == hash.end()) {
				//cout << "NE moze " << b[i] << " NE POSOJI" << endl;
				ne = true;
				continue;
			}
			hash.at((ll)abs(b[i]))--;
			if(hash.at((ll)abs(b[i])) < 0) ne = true;
		}
	}
	//cout << ne << endl;
	if(ne) return "NE";
	return "DA";
}

int main()
{
	int t;
	cin >> t;
	string res[t];
	for(int i = 0; i < t; i++)
		res[i] = slucaj();
	for(int i = 0; i < t; i++)
		cout << res[i] << endl;
	
}