#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 parnih=n-k;
	int nparnih = k-parnih;
	int suma =0; 
	if(np%2==0){
		suma = parnih*(np*(np+1))/2 + nparnih*(p*(p+1))/2;
	}else{
		suma = nparnih*(np*(np+1))/2 + parnih*(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!=0 && suma<=m){
		cout<<"Tak"<<endl;
	
	}else{

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



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

	}

}