#include <bits/stdc++.h>

using namespace std;

void solve(int t, int n[], int m[], int k[])
{
    for (int i = 0; i < t; i++)
    {
        if (k[i] == 1)
        {
            if ((n[i] * (n[i] + 1)) / 2 <= m[i])
                cout << "Tak" << endl;
            else
                cout << "Nie" << endl;
        }
        else if (n[i] == m[i])
            cout << "Nie" << endl;
        else
        {
            --m[i];
            if ((n[i] * (n[i] + 1)) / 2 <= m[i])
                cout << "Tak" << endl;
            else
                cout << "Nie" << endl;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cerr.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    int n[t], m[t], k[t];
    for (int i = 0; i < t; i++)
        cin >> n[i] >> m[i] >> k[i];
    solve(t, n, m, k);
    return 0;
}