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

void aaaa() {
	int n;
	cin >> n;
	map<int,int> a;
	map<int,int> b;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (i % 2 == 0) t = -t;
		a[t]++;
	}
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (i % 2 == 0) t = -t;
		b[t]++;
	}
	for (pair<int, int> p : a) {
		if (b[p.first] != p.second) {
			cout << "NE" << endl;
			return;
		}
	}
	cout << "DA" << endl;


}

int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		aaaa();
	}
}