#include <iostream>
using namespace std;
long long i;
long long nig[100];
int main()
{
    long long t;
    cin >> t;
    long long n[100], m[100], k[100];
    for(i=0;i<t;++i)
    {
        cin >> n[i] >> m[i] >> k[i];
    }
    //zbir prvih n
    long long j=0;
    for(j=0;j<t;++j)
        for(i=0;i<=n[j];++i)
            nig[j] = nig[j] + i;
    //res
    for(i=0;i<t;++i)
    {
        if((n[i]<k[i]) || (n[i]>m[i]))
        {
            cout << "Nie" << endl;
        }
        else{
            if(k[i] != 1)
            {
            for(j=0;j<t;++j)
                for(i=0;i<=n[j];++i)
                    nig[j] = nig[j] + i;
            n[i]/=k[i];
            m[i]/=k[i];
            nig[i]/=k[i];

            }
            if(m[i] >= nig[i])
            {
                cout << "Tak" << endl;
            }
            else
            {
                cout << "Nie" << endl;
            }
        }

    }
    return 0;
}