#include <iostream>

using namespace std;

int main()
{
    int T;
    cin >> T;
    int N, M, K;
    bool rez[T];
    for(int i = 0; i < T; i++) {
        cin >> N >> M >> K;
        int p = N / K;
        int q = p + N % K;
        int pB = M / K;
        int qB = pB + M % K;
        qB = qB + (K-1)*(pB-(p*(p+1)/2));
        if(qB >= q*(q+1)/2) {
            rez[i] = true;
        }else {
            rez[i] = false;
        }
    }
    for(int i = 0; i < T; i++) {
        if(rez[i]) {
            cout << "Tak";
        }else {
            cout << "Nie";
        }
        cout << endl;
    }
}