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

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


}
return 0;
}