include <iostream>
#include <vector>
#include <string>
#define ull unsigned long long

using namespace std;

int main() {
	int t;
	ull n, m, k;
	cin >> t;
	int i, j;
	vector<string> result;
	result.resize(t);
	for (i = 0; i < t; i++) {
		cin >> n >> m >> k;
		ull q = n / k;
		ull r = n % k;
		q++;
		ull a = q * (q + 1) / 2;
		for (j = 0; j < r; j++) {
			if (m > a)
				m -= a;
			else 
				result[i] = "Nie";
		}
		q--;
		a = q * (q + 1) / 2;
		for (j = 0; j < k - r + 1; j++) {
			if (m > a)
				m -= a;
			else 
				result[i] = "Nie";
		}
		if (m > q)
			result[i] = "Tak";
		else 
			result[i] = "Nie";
	}

	for (auto r : result)
		cout << r << "\n";

	return EXIT_SUCCESS;
}