#include<bits/stdc++.h>
using namespace std;
long long t,n,m,k,v,a,l,a1,a2,aa1,aa2,mg,vg,bb;
int main(){
cin>>t;
for(int i=1; i<=t; i++){
    v=0;
    l=0;
    mg=0;
    vg=0;
    aa1=0;
    a1=0;
    aa2=0;
    a2=0;
    bb=0;

    cin>>n>>m>>k;
    v=n/k;
    l=n%k;
    mg=k-l;
    vg=l;


    aa1=((v+1)*(v+2))/2;

    aa2=((v)*(v+1))/2;

    a1=vg*aa1;
    a2=mg*aa2;
    bb=a1+a2;

    if(n==k and m>=n){
        cout<<"Tak"<<endl;
    }

    else if(n>k and m>=bb){
        cout<<"Tak"<<endl;
    }
    else{
        cout<<"Nie"<<endl;
    }

}


return 0;
}