using System;
using System.Collections.Generic;

namespace Razmena_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine()), n, data, index, x, parna_a, neparna_a, parna_b, neparna_b, removed;
            string[] input;
            bool[] r = new bool[t];
            List<int> a, a_copy, b;
            for (int i = 0; i < t; i++)
            {
                r[i] = true;
                n = Convert.ToInt32(Console.ReadLine());
                a = new List<int>();
                b = new List<int>();;
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++)
                {
                    data = Convert.ToInt32(input[j]);
                    a.Add(data);
                }
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++)
                {
                    data = Convert.ToInt32(input[j]);
                    b.Add(data);
                }
                a_copy = new List<int>(a);
                removed = 0;
                while (a_copy.Count > 0)
                {
                    parna_a = 0;
                    neparna_a = 0;
                    parna_b = 0;
                    neparna_b = 0;
                    x = a_copy[0];
                    while ((index = a.IndexOf(x)) >= 0)
                    {
                        if (index % 2 == 0) parna_a++; else neparna_a++;
                        a[index] = 1000000001;
                        a_copy.RemoveAt(index - removed++);
                    }
                    while ((index = b.IndexOf(x)) >= 0)
                    {
                        if (index % 2 == 0) parna_b++; else neparna_b++;
                        b[index] = 1000000001;
                    }
                    while ((index = b.IndexOf(-x)) >= 0)
                    {
                        if (index % 2 == 0) neparna_b++; else parna_b++;
                        b[index] = 1000000001; ;
                    }
                    if (parna_a != parna_b || neparna_a != neparna_b)
                    {
                        r[i] = false;
                        break;
                    }
                }
                //manji od 0 obrni poziciju i dodaj parne i uporedi sa starim
            }
            foreach(bool rez in r)
            {
                Console.WriteLine((rez?"DA":"NE"));
            }
        }
    }
}