#include <iostream>

using namespace std;

int main()
{
    int t, n;
    int possible = 1;
    cin >> t;
	int pa[t];
    for(int k = 0; k < t; k++){
    	pa[k] = 1;
    	cin >> n;
    	int a[n], b[n];
    	for(int j = 0; j < n; j ++){
    		cin >> a[j];
		}
		for(int j = 0; j < n; j ++){
    		cin >> b[j];
		}
		for (int i = 0; i < n; i++) {
        	if(a[i] != b[i]){
        			int temp = a[i];
        			a[i] = -a[i + 1];
        			a[i + 1] = - a[i];
			}
    	}
    	for (int i = 0; i < n; i++) {
        	if(a[i] != b[i]){
        		pa[k] = 0;
        		break;
			}
    	}
	}
	for(int k = 0; k < t; k++){
		if(pa[k] == 1){
			cout << "DA" << endl;
		}
		else{
			cout << "NE" << endl;
		}
	}
    return 0;
}