1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const unsigned long MAX_N = 1000000000;

vector<unsigned long> fiboSeries;

void precomputing() {
	unsigned long f0, f1, f;

	f0 = 0;
	f1 = 1;
	f = f0 + f1;

	fiboSeries.push_back(f0);
	fiboSeries.push_back(f1);


	while (f <= MAX_N) {
		fiboSeries.push_back(f);
		f0 = f1;
		f1 = f;
		f = f0 + f1;
	}
}

string solve(unsigned long n) {
	for (vector<unsigned long>::size_type i = 0; i < fiboSeries.size(); i++) {
		for (vector<unsigned long>::size_type j = 0; j < fiboSeries.size(); j++) {
			if (fiboSeries[i] * fiboSeries[j] == n) {
				return "TAK";
			}
		}
	}
	return "NIE";
}

int main() {
	precomputing();
	ios_base::sync_with_stdio(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		unsigned long n;
		cin >> n;
		cout << solve(n) << endl;
	}
	return 0;
}