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

struct gdje{
bool f=false;
int p=0;
};

int main()
{
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<ull> a(n),b(n);
        for(int i=0;i<n;i++)cin>>a[i];
        map<ull,gdje> mp;
        for(int i=0;i<n;i++){
            cin>>b[i];
            gdje x;
            x.f=true;
            x.p=i%2;
            mp[b[i]]=x;
        }
        for(int i=0; i<n; i++){
            if(mp[a[i]].f==true && i%2==mp[a[i]].p){
                mp[a[i]].f=false;
                continue;
            }
            if(mp[-a[i]].f==true && i%2!=mp[-a[i]].p){
                mp[-a[i]].f=false;
                continue;
            }
            cout << "NE\n";
            goto endd;
        }
        cout << "DA\n";
        endd:;
    }
    return 0;
}