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

int main() 
{
    int t, n, br1, br2;
    vector<int> A;
    vector<int> B;
    cin >> t;
    for(int i = 0; i < t; i++) {
        cin >> n;
        A.resize(n); B.resize(n);
        for(int i = 0; i < n; i++) { cin >> A.at(i); if(A.at(i) != 0) { br1 = i; } }
        for(int i = 0; i < n; i++) { cin >> B.at(i); if(B.at(i) != 0) { br2 = i; } }
        if(abs(A.at(br1)) != abs(B.at(br2))) {
            cout << "NE" << endl;
            continue;
        }
        if(br1 % 2 == br2 % 2) {
            if(-A.at(br1) == B.at(br2))
            {
                cout << "NE" << endl;
                continue;
            }
            else
            {
                cout << "DA" << endl;
                continue;
            }
        }
        else
        {
            if(-A.at(br1) == B.at(br2))
            {
                cout << "DA" << endl;
                continue;
            }
            else
            {
                cout << "NE" << endl;
                continue;
            }
        }
    }   
    return 0;
}