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

const int lastFibo = 46;
int array[lastFibo];

void fillTheArray(){
	array[0] = 0;
	array[1] = 1;
	for (int i = 2; i < lastFibo; i++){
		array[i] = array[i - 2] + array[i - 1];
	}
}

void printArray(){
	for (int i = 0; i < lastFibo; i++){
		printf("array[%i] = %i\n", i, array[i]);
	}
}

bool isFibonacciNumber(int number){
	for (int i = 0; i < lastFibo; i++){
		if (array[i] == number){
			return true;
		}
	}
	return false;
}

bool isInFibonacciArray(int number, int startIndex){
	for (int i = startIndex; i < lastFibo - 1; i++){
		if (array[i] == number){
			return true;
		}
	}
	return false;
}

bool isFibonacciProduct(int number){

	for (int i = 3; i < lastFibo - 1; i++){
		if (number % array[i] == 0){
			if (isInFibonacciArray(number / array[i], i)){
				return true;
			}
		}
	}

	return false;
}

void process(int number){
	if (isFibonacciNumber(number)){
		printf("TAK\n");
	}
	else if (isFibonacciProduct(number)){
		printf("TAK\n");
	}
	else{
		printf("NIE\n");
	}
}


int main(){
	fillTheArray();

	int number_of_tests;
	int number;
	
	scanf("%i", &number_of_tests);
	while (number_of_tests > 0){
		scanf("%i", &number);

		process(number);

		--number_of_tests;
	}

	return 0;
}