#include <iostream>
using namespace std;

int br(int a){
    int br=0;
    for(int i=1; i<a; i++){
		if(a%i==0){
			br++;
		}
	}
    return br;
}

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

    int t, ucenici, ekipe;
    long long bananice;
    cin>>t;

	do{
	cin>>ucenici>>bananice>>ekipe;

    if(ekipe>ucenici){
        cout<<"Nie"<<'\n';
    }
    if(bananice<ucenici){
        cout<<"Nie"<<'\n';
    }
    if(br(bananice)<ucenici){
        cout<<"Nie"<<'\n';
    }else cout<<"Tak"<<'\n';

    t=t-1;
	}while(t>0);

    return 0;
}