#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--)
    {
        ll n,m,k;
        cin>>n>>m>>k;
        ll x=n/k;
        ll y=n-x*k;
        if(m>=y*(x+1)*(x+2)/2+(k-y)*x*(x+1)/2) cout<<"Tak"<<endl;
        else cout<<"Nie"<<endl;
    }
    return 0;
}