#include <iostream>

using namespace std;

int main()
{
    int t, sum = 0;

    cin >> t;

    long long int n[t], m[t], k[t];

    int l, ost, pom;

    for(int i = 0; i < t; i++){

        cin >> n[i] >> m[i] >> k[i];
    }

    for(int i = 0; i < t; i++){

        if(k[i] == 1){
            for(n[i]; n[i] > 0; n[i]--){

                sum += n[i];
            }
        }
        if(k[i]>1){
                
            l = n[i]/k[i];
        
            pom = l;
            
            ost = n[i]%k[i];
            
            for(l; l > 0; l--){
                    
                sum=sum+(l*k[i]);
            }
            sum = sum + (pom+1)*ost;
            
            cout << sum<< endl;
        }
        if(m[i]>=sum) cout << "Tak" << endl;
        
        else cout << "Nie" << endl;
        
        sum = 0;
    }
    return 0;
}