using System;
class HelloWorld
{
    static bool Check(int n, int[] a, int[] b)
    {
        int i = 0;
        for (i = 0; i < n; i++)
        {
            if (a[i] != b[n - 1 - i] * (-1)) return false;
           
        }
        return true;
    }
    static void Main()
    {
        int T = int.Parse(Console.ReadLine());
        while (T > 0)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            int[] b = new int[n];
            var s = Console.ReadLine().Split();
            var d = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
                b[i] = int.Parse(d[i]);
            }
            if (Check(n, a, b))
            {
                Console.WriteLine("DA");
            }
            else Console.WriteLine("NE");
            T--;
        }
    }
}