#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t,n;
    bool provera;
    cin >> t;
    for (int r = 0; r < t; r++)
    {
        provera = true;
        cin>>n;
        long long a[n], b[n];
        for(int i = 0; i < n; i++)
        {
            cin>>a[i];
        }
        for(int i = 0; i < n; i++)
        {
            cin>>b[i];
        }
        else{
            for(int i = 0; i < n && provera == true; i++)
            {
                for (int k = 0; k < n && provera == true; k++)
                {
                    if(abs(a[k]) == abs(b[i]))
                    {
                        if((k - i)%2 == 0)
                        {
                            if(a[k] == b[i]){
                                a[k] = 0;
                                break;
                            }
                            else if(k == n-1){
                                provera = false;
                                cout << "NE" << endl;
                                break;
                            }
                        }
                        else{
                            if(a[k] == -b[i]){
                                a[k] = 0;
                                break;
                            }
                            else if(k == n-1){
                                provera = false;
                                cout << "NE" << endl;
                                break;
                            }
                        }
                    }
                    else if(k == n-1){
                        provera = false;
                        cout << "NE" << endl;
                    }
                }
            }
        }
        if (provera == true)
        {
            cout << "DA" << endl;
        }
    }
    return 0;
}