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
53
54
55
#include<iostream>
#include<vector>

void fill(std::vector<unsigned long long> &fibs, unsigned long long n)
{
	fibs.emplace_back(0);
	fibs.emplace_back(1);

	while(fibs.back() < n)
		fibs.emplace_back(fibs.back() + fibs[fibs.size() - 2]);
}

bool product(const std::vector<unsigned long long> &fibs, unsigned long long n)
{
	std::vector<unsigned long long>::const_iterator it = fibs.cbegin();
	std::vector<unsigned long long>::const_iterator it2 = fibs.cend() - 1;

	while(it != it2)
	{
		unsigned long long r = *it * *it2;

		if(r < n)
			++it;
		else if(r > n)
			--it2;
		else
			return true;
	}

	unsigned long long r = *it;
	return r * r == n;
}

int main()
{
	std::ios_base::sync_with_stdio(false);

	unsigned t;
	std::cin >> t;
	while(t--)
	{
		unsigned long long n;
		std::cin >> n;

		std::vector<unsigned long long> fibs;
		fill(fibs, n);

		if(product(fibs, n))
			std::cout << "TAK" << std::endl;
		else
			std::cout << "NIE" << std::endl;
	}

	return 0;
}