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

long long int nkrozk(int n, int k)
{
	long long int a[k];
	long long int zb = 0, br = 0;
	int i = 0;
	for (int i = 0; i < k; i++)
	{
		a[i] = 1;
		zb += a[i];
		br++;
	}
	i = 0;
	while (br < n)
	{
		a[i]++;
		zb += a[i];
		br++;
		i++;
		if(i == k)
			i = 0;
	}

	return zb;
}

int main()
{
	int t;
	scanf("%d", &t);
	int n[t], k[t];
	long long int m[t];
	for (int i = 0; i < t; i++)
		scanf("%d %lld %d", &n[i], &m[i], &k[i]);


	for (int i = 0; i < t; i++)
	{
		//printf("%d %lld\n", nkrozk(n[i], k[i]), m[i]);
		if (nkrozk(n[i], k[i]) > m[i])
			printf("Nie\n");
		else
			printf("Tak\n");
	}
}