using System;

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = Int32.Parse(Console.ReadLine());
            string[] a = new string[t];
            for (int i = 0; i < t; i++)
            {
                var b = Console.ReadLine().Split(' ');
                int n = Int32.Parse(b[0]);
                long m = Int64.Parse(b[1]);
                int k = Int32.Parse(b[2]);
                int p = n / k;
                int p1 = p + 1;
                int c = (p * ((p - 1) / 2)) + p * (p % 2);
                int c1 = (p1 * ((p1 - 1) / 2)) + p1 * (p1 % 2) * (n - (p * k));
                if (m >= ((k-(p * k)) * c) + c1)
                {
                    a[i]="Tak";
                }
                else
                {
                    a[i]="Nie";
                }
            }
            foreach (var x in a)
            {
                Console.WriteLine(x);
            }
        }
    }
}