#include <bits/stdc++.h>
using namespace std;
int t, arr[100009], n, m, k;
int main() {
cin >> t;
while (t--) {
cin >> n >> m >> k;
int temp = n/k;
int doc = n%k;
for (int i = 1; i <= k; i++) {
    arr[i] = temp;
    if (i <= doc) {
        arr[i]++;
    }
}

for (int i = 1; i <= n; i++) {
    n -= (arr[i]*(arr[i]+1)/2);
    if (n<0) {
        cout << "Nie" << "\n";
        continue;
    }
}
if (n >= 0) {
    cout << "Tak" << "\n";
}


}
return 0;
}