#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=0,n,i=0,j=0;cin >> t;
    while(t--){
        cin >> n;
        int nega=0, negb=0;
        i=0;
        j=n-1;
        vector<int>a(n);
        vector<int>b(n);
        for(int i2=0;i2<n;i2++){cin >> a[i2];if(a[i2]<0)nega++;}
        for(int i2=0;i2<n;i2++){cin >> b[i2];if(b[i2]<0)negb++;}
        if(equal(a.begin(),a.end(),b.begin(),b.end())){
            cout << "DA" << "\n";
            continue;
        }
        if(abs(nega-negb)%2==1){
            cout << "DA" << "\n";
            continue;
        }
        while(a[i]==b[i+1]*(-1) && a[i+1]==b[i]*(-1)){a[i]*=(-1);a[i+1]*=(-1); swap(a[i],a[i+1]);i+=2;}
        if(equal(a.begin(),a.end(),b.begin(),b.end())){
            cout << "DA" << "\n";
            continue;
        }
        while(a[i]==b[j]*(-1) && a[j]==b[i]*(-1)){a[i]*=(-1);a[j]*=(-1); swap(a[i],a[j]);i++;j--;}


        if(equal(a.begin(),a.end(),b.begin(),b.end())){
            cout << "DA" << "\n";
            continue;
        }
        cout << "NE" << endl;
        continue;
    }
    return 0;
}