#include <bits/stdc++.h>

using namespace std;

vector<int> obrniNiz(int A[], int N){
    vector<int> obrnutiNiz;
    for(int i = 0; i < N;i++){
        obrnutiNiz.push_back(-(A[N-i-1]));
    }
    return obrnutiNiz;
}

int main()
{
    vector<string> res;
    int T;
    cin >> T;
    for(int i = 0; i <= T; i++){
        int N;
        cin >> N;
        int A[N],B[N];
        for(int j = 0; j < N; j++){
            cin >> A[j];
        }
        vector<int> obrnutiAniz = obrniNiz(A,N);

        for(int j = 0; j < N; j++){
            cin >> B[j];
            if(B[j] != obrnutiAniz[j]){
                res.push_back("NE");
                break;
            }
            else{
                if(j == N-1){
                    res.push_back("DA");
                }
            }
        }
    }
    for(int i = 0; i < res.size(); i++){
            cout << res[i] << endl;
        }
    return 0;
}