using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i<t;i++)
            {
                int l = 0;
                int n = Convert.ToInt32(Console.ReadLine());
                string a = Console.ReadLine();
                string b = Console.ReadLine();
                for(int j = 0; j < n; j++)
                {
                    for(int k = 0; k < n; k++)
                    {
                        if(a[i] == b[k])
                        {
                            l++;
                            break;
                        }
                    }
                }
                if (l == n)
                {
                    Console.WriteLine("DA");
                }
                else
                {
                    Console.WriteLine("NE");
                }
            }
            Console.ReadLine();
        }
    }
}