#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin>>t;

    for (int j=0;j<t;j++)
    {
        long long n,m,k;
        cin>>n>>m>>k;

        long long br_clanova=n/k;
        long long br_krajnjih_clanova=n-(k-1)*br_clanova;

        m=m-(k-1)*((br_clanova*(br_clanova+1))/2);

        m=m-((br_krajnjih_clanova*(br_krajnjih_clanova-1))/2);

        if (m>=br_krajnjih_clanova)
        {
            cout<<"Tak";
        }

        else
        {
            cout<<"Nie";
        }

        cout<<endl;
    }
}