#include <bits/stdc++.h>
using namespace std;

int main(){
    int t,n,k,brClan1,brClan2,veca, rez1, rez2, rez;
    long long m;
    cin>>t;
    string arr[t];
    for(int i=0; i<t; i++){
        cin>>n>>m>>k;
        if(n>m){
            arr[i]="Nie";
        }
        else{
            brClan1=n/k;
            brClan2=brClan1 + 1;
            veca=n%k;
            if(brClan1 % 2 != 0)
                rez1=(brClan1+1)*(brClan1-1)/2)+(brClan1+1)/2;
            else
                rez1=(brClan1+1)*brClan1/2;

            if(brClan2 % 2 != 0)
                rez2=(brClan2+1)*((brClan2-1)/2)+(brClan2+1)/2;
            else
                rez2=(brClan2+1)*brClan2/2;

            rez=(k-veca)*rez1 + veca*rez2;

            if(rez<=m)
                arr[i]="Tak";
            else
                arr[i]="Nie";
        }
    }
    for(int i=0; i<t; i++)
        cout<<arr[i]+"\n";
    return 0;
}