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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <vector>
using namespace std;
const unsigned int MAX=1000000000;
vector <int> fib;

bool bin (int c)
{
	int l=0,r=fib.size()-1;
	while (l<=r)
	{
		int mid=l+(r-l)/2;
		if(fib[mid]==c)
			return 1;
		else if (fib[mid]>c)
			r=mid-1;
		else
			l=mid+1;
	}
	return 0;
}

void read()
{
	int a=1,b=1;
	fib.push_back(a);
	bool p=1;
	while(a<=MAX && b<=MAX)
	{
		if(p)
		{
			b+=a;
			fib.push_back(b);
			p=0;
		}
		else
		{
			a+=b;
			fib.push_back(a);
			p=1;
		}
	}
}

void solve()
{
	int m,pom;
	bool p;
	cin>>m;
	for (int i=0;i<m;i++)
	{
		p=1;
		cin>>pom;
		if (bin(pom))
		{
			cout<<"TAK\n";
			p=0;
		}
		else
		{
			int j=1;
			while (pom/2>=fib[j])
			{
				if (pom%fib[j] ==0 && bin(pom/fib[j]))
				{
					cout<<"TAK\n";
					p=0;
					break;
				}
				j++;
			}
		}
		if (p)
			cout<<"NIE\n";
	}
}

int main()
{
	 read();
	 solve();
	 fib.pop_back();
     return 0;
}