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
#include <stdio.h>
#include <math.h>

bool isSquare(long number)
{
	long result = (long)sqrt(number);
	return number == result*result;
}

bool isFibbonaci(long number)
{
	if(isSquare(5*number*number-4) || isSquare(5*number*number+4))
	{
		return true;
	}
}

bool isOk(long number)
{
	if(number == 0 || number == 1)
		return true;
		
	if(isFibbonaci(number))
		return true;
	
	int res = (int) sqrt(number);
	
	for(int i=2; i <= res; i++)
	{
		if(number % i == 0 && isFibbonaci(i) && isFibbonaci(number/i))
			return true;
	}
	
	return false;
}

int main()
{
	int count;
	scanf("%d", &count);
	
	while(count--)
	{
		long number;
		scanf("%ld", &number);
		if(isOk(number))
		{
			printf("TAK\n");
		}
		else
		{
			printf("NIE\n");
		}
	}
	
	return 0;
}