using System;

namespace zadatak_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            int[] n = new int[t];
            int[] m = new int[t];
            int[] k = new int[t];
            int x = 0;
            bool[] ok = new bool[t];
            for (int i = 0; i < t; i++)
            {
                string[] s = Console.ReadLine().Split();
                n[i] = int.Parse(s[0]);
                m[i] = int.Parse(s[1]);
                k[i] = int.Parse(s[2]);
            }
            for (int i = 0; i < t; i++)
            {
                int[] niz = new int[k[i]];
                int[] niz_bananica = new int[n[i]];
                if (n[i] < k[i] || m[i] < n[i])
                    ok[i] = false;
                else if (m[i] == n[i] && k[i] == 1)
                    ok[i] = false;
                else
                {
                    int c = n[i] / k[i];
                    for (int j = 0; j < k[i]; j++)
                    {
                        niz[j] = 1;
                    }
                    x = n[i] - k[i];
                    if (x == 0)
                        break;
                    else
                    {
                        for (int j = 0; j < k[i]; j++)
                        {
                            if (x > 0)
                            {
                                niz[j] += 1;
                                x--;
                            }
                            else
                                break;
                        }
                    }

                    int s = 0;
                    niz_bananica[0] = 1;
                    for (int d = 1; d < n[i] - 1; d++)
                    {
                        niz_bananica[d] = niz_bananica[d - 1] + 1;
                        s = s + niz_bananica[d];
                    }
                    niz_bananica[n[i] - 1] = m[i] - s - 1;
                    ok[i] = true;
                    for (i = 0; i < k[i]; i++)
                    {
                        for (int d = 1; d < n[i] - 1; d++)
                        {
                            for (int u = d + 1; u < n[i]; u++)
                            {
                                if (niz_bananica[d] == niz_bananica[u])
                                    ok[i] = false;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < t; i++)
            {
                if (ok[i])
                    Console.WriteLine("Tak");
                else
                    Console.WriteLine("Nie");
            }
            }
        }
    }