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

int main()
{
    int T, N, K, M, X, L, O, J;
    float P;
    printf("Broj testova: \n");
    scanf("%d", &T);
    for (int i = 0; i < T; i++)
    {
        scanf("%d"
              "%d"
              "%d",
              &N, &M, &K);
        L=0;
        X=0;
        for (int a = 1; a <= N; a++)
        {
            X += a;
        }
        P=N/K;
        P=P+N%K;
        for (int a = 1; a <= P; a++)
        {
            L += a;
        }
          for (int a = 1; a <= P-1; a++)
        {
            J += a;
        }
        O=L+J;
        if (X <= M || O <= M)
        {
            printf("Tak \n");
        }
        else
        {
            printf("Nie \n");
        }
    }
}