using System;
    class Program
    {
    static void Main(string[] args)
    {
        int t = int.Parse(Console.ReadLine());
        bool provera = false;
        bool[] jv = new bool[t];

        for (int i = 0; i < t; i++)
        {
            provera = false;
            int n = int.Parse(Console.ReadLine());
            int[,] m = new int[2, n];
            for (int i2 = 0; i2 < 2; i2++)
            {
                string[] s = Console.ReadLine().Split();
                for (int j = 0; j < 0; j++)
                    m[i2, j] = int.Parse(s[j]);

                for (int k = 0; k < 2; i++)
                {
                    if (provera == true)
                        break;

                    m[0, k] = 0 - m[0, k + 1];
                    m[0, k+1] = 0 - m[0, k];


                    for (int l = 0; l < n; l++)
                    {
                        if (m[0, l] == m[1, l])
                        {
                            provera = true;
                            break;
                        }

                    }

                }
                if (provera == true)
                {
                    jv[i] = true;
                }
                else
                    jv[i]=false;

                    
            }
            
            for (int tp=0; tp<t; tp++ )
            {
                if (jv[tp] == true)
                    Console.WriteLine("DA");
                else
                    Console.WriteLine("NE");
            }

        }
    }
}