#include <bits/stdc++.h>
#define here cerr<<"==========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define ll long long
#define endl '\n'
#define sz(a) (ll)(a.size())
#define fi first
#define sc second
#define pll pair<ll,ll>
#define llinf 1000000000LL
#define pb push_back
using namespace std;
#define maxn 30005
ll n;
ll a[maxn],b[maxn];
multiset<ll> v[2];
int main()
{
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cerr.tie(0);
    int t; cin >> t;
    while(t--){
        v[0].clear();
        v[1].clear();
        cin >> n;
        for(ll i = 1;i<=n;i++) cin >> a[i];
        for(ll i = 1;i<=n;i++) cin >> b[i];
        for(ll i = 1;i<=n;i++){
            ll e = (i&1);
            v[e].insert(a[i]);
            v[e^1].insert(-a[i]);
        }
        bool ok = 1;
        for(ll i = 1;i<=n;i++){
            ll e = (i&1);
            ll x = b[i];
            if(v[e].find(x)==v[e].end()){ok = 0;break;}
            else{
                v[e].erase(v[e].find(x));
                v[e^1].erase(v[e^1].find(-x));
            }
        }
        if(ok) cout<<"DA"<<endl;
        else cout<<"NE"<<endl;
    }
    return 0;
}