#include <bits/stdc++.h>
using namespace std;

//      Starting Kit     (START)
typedef long long ll;
#define INF INT_MAX
#define MOD (1e9+7)

#define pii pair<int, int>
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
#define print_vect(v) for (auto it : v) cout << it << " ";
//      Starting Kit     (END)

void solve(int n, int m, int k) {

    if (n == 3) { // 10p
        if (k == 1) {
            int u1 = 1, u2 = 2, u3 = m-3;
            if (u3 > u1 && u3 > u2) { cout << "Tak" << endl; return; }
            else { cout << "Nie" << endl; return; }
        }
        if (k == 2) {
            int u = m-2;
            if (u > 1) { cout << "Tak" << endl; return; }
            else { cout << "Nie" << endl; return; }
        }
        if (k == 3) {
            if (m >= 3) { cout << "Tak" << endl; return; }
            else { cout << "Nie" << endl; return; }
        }

    } else if (k == 1) { // 10p

        int sum = 0;
        for (int i = 1; i <= n-1; ++i) sum += i;
        if (m-sum > n-1) { cout << "Tak" << endl; return; }
        else { cout << "Nie" << endl; return; }
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t; cin >> t;

    while (t--) {
        int n, m, k; cin >> n >> m >> k;
        solve(n, m, k);
    }

    return 0;
}