#include <bits/stdc++.h>
using namespace std;
int rezultat(int brClan){
    int rezPom;
    if(brClan % 2 != 0)
        rezPom=(brClan+1)*((brClan-1)/2)+(brClan+1)/2;
    else
        rezPom=(brClan+1)*brClan/2;
    return rezPom;
}
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;
            rez1=rezultat(brClan1);
            rez2=rezultat(brClan2);
            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;
}