1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <set>

using namespace std;

long unsigned possible[]={0,1,2,3,4,5,6,8,9,10,13,15,16,21,24,25,26,34,39,40,42,55,63,64,65,68,89,102,104,105,110,144,165,168,169,170,178,233,267,272,273,275,288,377,432,440,441,442,445,466,610,699,712,714,715,720,754,987,1131,1152,1155,1156,1157,1165,1220,1597,1830,1864,1869,1870,1872,1885,1974,2584,2961,3016,3024,3025,3026,3029,3050,3194,4181,4791,4880,4893,4895,4896,4901,4935,5168,6765,7752,7896,7917,7920,7921,7922,7930,7985,8362,10946,12543,12776,12810,12815,12816,12818,12831,12920,13530,17711,20295,20672,20727,20735,20736,20737,20740,20761,20905,21892,28657,32838,33448,33537,33550,33552,33553,33558,33592,33825,35422,46368,53133,54120,54264,54285,54288,54289,54290,54298,54353,54730,57314,75025,85971,87568,87801,87835,87840,87841,87843,87856,87945,88555,92736,139104,141688,142065,142120,142128,142129,142130,142133,142154,142298,143285,150050,225075,229256,229866,229955,229968,229970,229971,229976,230010,230243,231840,370944,371931,372075,372096,372099,372100,372101,372109,372164,372541,375125,600200,601797,602030,602064,602069,602070,602072,602085,602174,602784,973728,974105,974160,974168,974169,974170,974173,974194,974338,975325,1575525,1576135,1576224,1576237,1576239,1576240,1576245,1576279,1576512,2550240,2550384,2550405,2550408,2550409,2550410,2550418,2550473,2550850,4126375,4126608,4126642,4126647,4126648,4126650,4126663,4126752,6676992,6677047,6677055,6677056,6677057,6677060,6677081,6677225,10803600,10803689,10803702,10803704,10803705,10803710,10803744,17480736,17480757,17480760,17480761,17480762,17480770,17480825,28284425,28284459,28284464,28284465,28284467,28284480,45765216,45765224,45765225,45765226,45765229,45765250,74049675,74049688,74049690,74049691,74049696,119814912,119814915,119814916,119814917,119814925,193864600,193864605,193864606,193864608,313679520,313679521,313679522,313679525,507544125,507544127,507544128,821223648,821223649,821223650};
set<long unsigned> possibleSet(possible,possible+301);

int main()
{
	long unsigned l;
	int n;
	cin >> n;
	while (n--)
	{
		cin >> l;
		if (possibleSet.count(l)) cout << "TAK" << endl;
		else cout << "NIE" << endl;
	}
	return 0;
}