#include <iostream>

using namespace std;

int factorial(int n)
{
    if(n > 1) return n*factorial(n-1);
    else return 1;
}

int main ()
{
	int t;
	cin>>t;
	int n,k;
	long m;
	for(int xx=0;xx<t;xx++)
    {
        cin>>n>>m>>k;
        long ostatak;
        if(n%k!=0)
        {
            ostatak=m-(k*factorial(n/k)+((n%k)-1)*((n/k)+1));
            if(ostatak>(n/k)+1) cout<<"Tak"<<endl;
            else cout<<"Nie"<<endl;
        }
        else
        {
            if(m>k*factorial(n/k)) cout<<"Tak"<<endl;
            else cout<<"Nie"<<endl;
        }
    }
	return 0;
}