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
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector <long long int> fib;
vector <long long int> ilo;

bool sea(long long int p, long long int q, long long int r)
{
	if(p<=q)
	{
	 long long int s=(p+q)/2;
	 
		if(ilo[s]==r)
			return true;
		else
			if(ilo[s]>r)
 				return sea(p, s-1, r);
 			else
 				return sea(s+1, q, r);
 	}
 
 return false;
}

int main()
{
	long long int test, n;
	bool czy;
	
	fib.push_back(0);
	fib.push_back(1);
	fib.push_back(2);
	ilo.push_back(0);
	
	while(fib.back()+fib[fib.size()-2]<1000000000)
		fib.push_back(fib.back()+fib[fib.size()-2]);
		
	for(long long int i=1;i<fib.size();i++)
		for(long long int j=i;j<fib.size();j++)
			if(fib[i]*fib[j]>1000000000)
				break;
			else
				ilo.push_back(fib[i]*fib[j]);
	
	sort(ilo.begin(), ilo.end());
	scanf("%lld", &test);
	
	for(long long int x=0;x<test;x++)
	{
	 scanf("%lld", &n);
	 czy=sea(0, ilo.size()-1, n);
	 
	 	if(czy==true)
	 		printf("TAK\n");
	 	else
	 		printf("NIE\n");
	}
	
	return 0;
}