#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define ff(i,a,b) for(int (i) = (a);(i)<(b);(i)++)
#define fff(i,a,b) for(int (i) = (a);(i)<=(b);(i)++)

using namespace std;
using namespace __gnu_pbds;

int main()
{
    FAST;
    bool br = false;
    int t;
    cin>>t;
    ff(i,0,t){
        int n;
        cin>>n;
        int A[n+5];
        int B[n+5];
        fff(j,1,n){
            cin>>A[j];
        }
        fff(j,1,n){
            cin>>B[j];
        }
        fff(j,1,n){
            if(A[j]!= B[j]){
                if(A[j+1] != B[j+1]){
                    j++;
                }else{
                    cout<<"NE"<<endl;
                    br = true;
                    break;
                }
            }
        }
        if(br){
            br = false;
            continue;

        }
        cout<<"DA"<<endl;
    }
    return 0;
}