#include <bits/stdc++.h>


using namespace std;

void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	int np = (n/k)+1,p=n/k;
	int suma = (np*(np+1))/2 + (n/k-1)*(p*(p+1))/2;


	if(m>=(n*(n+1)/2) && k==1){
		cout<<"Tak"<<endl;
	}else if(n%k==0 && k*(n/k)*(n/k+1)/2<=m){
		cout<<"Tak"<<endl;
	}else if((n%k)%2==1 && suma<=m){
		cout<<"Tak"<<endl;
	
	}else{

		cout<<"Nie"<<endl;
	}
}



int main()
{
	int t; cin>>t;
	for(int i=0; i<t; i++){
		solve();

	}

}