#include<stdio.h>
#include<stdlib.h>

int main()
{
    int t,n,k,i,uc1,uc2,j;
    long int m,zbir=0;
    scanf("%d",&t);
    int niz[t];
    for (i=0;i<t;i++)
    {
        niz[i]=0;
        scanf("%d%ld%d",&n,&m,&k);
        uc1=n/k;
        uc2=n%k;
        for (j=1;j<=uc1;j++)
        {
            zbir=zbir+j;
        }
        for (j=1;j<k;j++)
        {
            if (m>=zbir)
                m=m-zbir;
            else
                niz[i]=1;
        }
        for (j=0;j<uc2;j++)
        {
            zbir=zbir+zbir+1;
        }
        if (m<zbir)
            niz[i]=1;
    }
    for (i=0;i<t;i++)
    {
        if (niz[i]==1)
            printf("Nie\n");
        else
            printf("Tak\n");
    }
}