using System;
using System.Collections.Generic;

namespace Razmena_cs
{
    class Parni
    {
        public int n, count;

        public Parni(int n, int count)
        {
            this.n = n;
            this.count = count;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine()), n, data, index, x, parna_a, parna_b, removed;
            string[] input;
            bool[] r = new bool[t];
            bool postoji;
            List<int> a, a_copy, b;
            List<Parni> brojevi;
            for (int i = 0; i < t; i++)
            {
                brojevi = new List<Parni>();
                r[i] = true;
                n = Convert.ToInt32(Console.ReadLine());
                a = new List<int>();
                b = new List<int>();;
                input = Console.ReadLine().Split(' ');
                postoji = false;
                for (int j = 0; j < n; j++)
                {
                    data = Convert.ToInt32(input[j]);
                    a.Add(data);
                    for(int z = 0; z < brojevi.Count; z++)
                    {
                        if(data == brojevi[z].n)
                        {
                            if (j % 2 == 0) brojevi[z].count++;
                            postoji = true;
                            break;
                        }
                    }
                    if (!postoji)
                    {
                        brojevi.Add(new Parni(data, (j % 2 == 0 ? 1 : 0)));
                    }
                }
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++)
                {
                    data = Convert.ToInt32(input[j]);
                    b.Add(data);
                    for (int z = 0; z < brojevi.Count; z++)
                    {
                        if (data == brojevi[z].n)
                        {
                            if (j % 2 == 0) brojevi[z].count--;
                            break;
                        }else if(-data == brojevi[z].n)
                        {
                            if(j % 2 == 1) brojevi[z].count--;
                            break;
                        }
                    }
                }
                foreach(Parni p in brojevi)
                {
                    if (p.count != 0)
                    {
                        r[i] = false;
                        break;
                    }
                }
            }
            foreach(bool rez in r)
            {
                Console.WriteLine((rez?"DA":"NE"));
            }
        }
    }
}