#include <iostream>
#include <string>

using namespace std;

void Zamena (int *a, int *b)
{
    int pom = *a;
    *a = *b;
    *b = pom;
}

int main()
{

   int t, n;
   int odg[100];
   cin >> t;

   for (int i = 0; i < t; i++)
   {
       int a[40000];
       int b[40000];
       int indikator = 0;


       cin >> n;

       int n1 = n;


     for (int i = 0; i < n; i++)
     {
         cin >> a[i];
     }
     for (int i = 0; i < n; i++)
     {
         cin >> b[i];
     }
     while (true)
     {
          for (int i = 0; i < n1 - 1; i++)
        {
            Zamena(&b[i], &b[i + 1]);

            b[i] = -b[i];
            b[i + 1] = -b[i + 1];

        }
        n1--;
        if (n1 == 1)
            break;
     }






   /* for (int i = 0; i < n; i++)
    {
       cout << a[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++)
    {
       cout << b[i] << " ";
    }
    cout << endl; */


    for (int i = 0; i < n; i++)
     {

         if (a[i] == b[i])
         {


         }
         else if (a[i] != b[i])
         {

             indikator = 1;
         }
     }

     odg[i] = indikator;

   }

    for (int i = 0; i < t; i++)
    {
        if (odg[i] == 1)
        {
            cout << "NE" << endl;
        }
        else if (odg[i] == 0)
        {
            cout << "DA" << endl;
        }
    }





    return 0;
}