#include <iostream>

using namespace std;

int main()
{
    int t = 0;
    cin >> t;
    bool canS[t];
    
    
    for (int i = 0; i < t; i++){
        canS[i] = true;
    }
    
    for (int i = 0; i < t; i++){
        canS[i] = true;
        int n;
        cin >> n;
        int niz1[n];
        int niz2[n];
        bool negative1 = false;
        int pos1 = 0;
        bool negative2 = false;
        int pos2 = 0;
        for (int s = 0; s < n; s++){
            canS[i] = true;
            cin>> niz1[s];
            if (niz1[s] != 0){
                if (niz1[s] < 0){
                    negative1 = true;
                }
                pos1 = s;
            }
        }
        for (int s = 0; s < n; s++){
            cin>> niz2[s];
            if (niz2[s] != 0){
                if (niz2[s] < 0){
                    negative2 = true;
                }
                pos2 = s;
            }
        }
        if (!negative1 && negative2 && abs(pos1 - pos2)% 2 == 0){
            canS[i] = false;
        }
        else if (negative1 && !negative2 && abs(pos1 - pos2)% 2 == 0){
            canS[i] = false;
        }
        else if (negative1 && negative2 && abs(pos1 - pos2)% 2 != 0){
            canS[i] = false;
        }
        else if (!negative1 && !negative2 && abs(pos1 - pos2)% 2 != 0){
            canS[i] = false;
        }
        
    }
    for (int i = 0; i < t; i++){
        if (canS[i]){
            cout << "DA" << endl;
        }
        else{
            cout << "NE" << endl;
        }
    }
}