#include <iostream>
#include <fstream>
#include <string>
#include <random>
using namespace std;

long long group_sum(int group_size, int group_cnt)
{
	return group_cnt * ((group_size * (group_size + 1)) / 2);
}

//void generate_testcases(int t)
//{
//	srand(time(0));
//	mt19937_64 gen(std::random_device{}());
//	for (int i = 0; i < t; i++)
//	{
//		ofstream input(to_string(i) + ".in");
//		long long n, m, k;
//		int test_cases = rand() % 10 + 1;
//		input << test_cases << endl;
//		while (test_cases--)
//		{
//			int type = rand() % 3;
//			if (type == 0)
//			{
//				n = rand() % 10 + 1;
//				m = rand() % 20 + 1;
//				k = rand() % n + 1;
//			}
//			else if (type == 1)
//			{
//				n = rand() % 20 + 1;
//				k = rand() % n + 1;
//
//				long long smaller_group_size = n / k;
//				long long larger_group_size = smaller_group_size + 1;
//				long long larger_group_cnt = n % k;
//				long long smaller_group_cnt = k - larger_group_cnt;
//				long long minimum_sum = group_sum(smaller_group_size, smaller_group_cnt) + group_sum(larger_group_size, larger_group_cnt);
//
//				m = minimum_sum + rand() % 10 - 5;
//			}
//			else
//			{
//				n = gen() % (long long)1e9 + 1;
//				m = gen() % (long long)(1e17) + 1;
//				k = gen() % n + 1;
//			}
//
//			input << n << " " << m << " " << k << endl;
//		}
//	}
//}

int main()
{
	//generate_testcases(50);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t; cin >> t;
	while (t--)
	{
		long long n, m, k; cin >> n >> m >> k;
		long long smaller_group_size = n / k;
		long long larger_group_size = smaller_group_size + 1;
		long long larger_group_cnt = n % k;
		long long smaller_group_cnt = k - larger_group_cnt;
		long long minimum_sum = group_sum(smaller_group_size, smaller_group_cnt) + group_sum(larger_group_size, larger_group_cnt);

		if (m >= minimum_sum) cout << "Tak" << endl;
		else cout << "Nie" << endl;
	}
}