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

namespace _19._12._2021._2
{
    class Program
    {
        public static int zbirprvihN(int n)
        {
            return n * (n + 1)/2;
        }
        public static string ekskurzija(int n,int m,int k)
        {
            if(k==1)
            {
                if(zbirprvihN(n)<=m)
                {
                    return "Tak";
                }
                else
                {
                    return "Nie";
                }
            }
            else
            {
                int p = (n - 1) / (k - 1),o= (n - 1) % (k - 1);
                if((k-1)*zbirprvihN(p)+o*(p+1)<m)
                {
                    return "Tak";
                }
                else
                {
                    return "Nie";
                }
            }
        }
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            string[] nz;
            var a = new List<string>();
            for (int i = 0; i < t; i++)
            {
                nz = Console.ReadLine().Split();
                int n=int.Parse(nz[0]), m= int.Parse(nz[1]), k = int.Parse(nz[2]);
                a.Add(ekskurzija(n, m, k));
            }
            foreach(string s in a)
            {
                Console.WriteLine(s);
            }
            Console.ReadLine();
        }
    }
}