using System;

namespace Ekskurzija_petlja
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            string[] p = new string[t];
            for (int i = 0; i < t; i++)
            {
                string[] s = Console.ReadLine().Split();
                int n = int.Parse(s[0]);
                int m = int.Parse(s[1]);
                int k = int.Parse(s[2]);
                int x = (n * (n + 1)) / 2;
                if ((k == 1 && m >= x) || (k > 1 && m >= x))
                    p[i] = "Tak";
                else if (k == m && n == m)
                    p[i] = "Tak";
                else
                    p[i] = "Nie";
            }
            for (int i = 0; i < t; i++)
                Console.WriteLine(p[i]);
        }
    }
}