/// Author: NemanjaSo2005
/// Date: 26th February 2023
/// Contest: Serbian high school regional contest
/// Anyone can use any part of this code for any purpose after the contest.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N,u,inv;
vector<int> X,Y;
ll min(ll a,int b){
   if(a<b)
      return a;
   return b;
}
ll min(int a,ll b){
   if(a<b)
      return a;
   return b;
}
ll max(ll a,int b){
   if(a>b)
      return a;
   return b;
}
ll max(int a,ll b){
   if(a>b)
      return a;
   return b;
}
void solve(){
   cin>>N;
   inv=1;
   for(int i=1;i<=N;i++){
      cin>>u;
      X.push_back(u*inv);
      inv*=-1;
   }
   inv=1;
   for(int i=1;i<=N;i++){
      cin>>u;
      Y.push_back(u*inv);
      inv*=-1;
   }
   sort(X.begin(),X.end());
   sort(Y.begin(),Y.end());
   for(int i=0;i<N;i++){
      if(X[i]!=Y[i]){
         cout<<"NE\n";
         return;
      }
   }
   cout<<"DA\n";
   return;
}
void reset(){
   X.clear();
   Y.clear();
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   int T=1;
   cin>>T;
   while(T--){
      solve();
      reset();
   }
   return 0;
}