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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t, n, x;
    cin >> t;
    vector <pair <int, int>> v1, v2;
    for (int i = 0; i < t; i++){
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> x;
            if (x < 0){
                v1.push_back(make_pair(abs(x), (i + 1) % 2));
            }
            else if (x == 0){
                v1.push_back(make_pair(0, 0));
            }
            else {
                v1.push_back(make_pair(x, i % 2));
            }
        }
        for (int i = 0; i < n; i++){
            cin >> x;
            if (x < 0){
                v2.push_back(make_pair(abs(x), (i + 1) % 2));
            }
            else if (x == 0){
                v2.push_back(make_pair(0, 0));
            }
            else {
                v2.push_back(make_pair(x, i % 2));
            }
        }
        sort(v1.begin(), v1.end());
        sort(v2.begin(), v2.end());
        if (v1 == v2){
            cout << "DA" << "\n";
        }
        else {
            cout << "NE" << "\n";
        }
        v1.clear();
        v2.clear();
    }
    return 0;
}