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
#include <iostream>
#include <math.h>
using namespace std;

bool isFibNumber(int n){
	float x = sqrt(5*n*n + 4);
	if((x*x) == (5*n*n + 4)) return true;
	x = sqrt(5*n*n - 4);
	if((x*x) == (5*n*n - 4)) return true;
	return false;
}

int* getFibArray(int n){
	int* ptrFibArray = new int[n];
	ptrFibArray[0] = 0;
	ptrFibArray[1] = 1;
	for(int i=2; i < n; i++){
		ptrFibArray[i] = ptrFibArray[i-1] + ptrFibArray[i-2];
	}
	return ptrFibArray;
}

int main() {
	unsigned int t = 0, n = 0;
	bool isOk;
	cin >> t;
	while(t--){
		cin >> n;
	 	if(isFibNumber(n)){
	 		cout << "TAK" << endl;
	 		continue;
	 	}
	 	isOk = false;
	 	int *fib = getFibArray(n);
 		for(int i=1; i < n; i++){
 			if(n % fib[i] == 0 && isFibNumber(n / fib[i])){
	 			isOk = true;
	 			break;
 			}
 		}
 		if(isOk) cout << "TAK" << endl;
 		else cout << "NIE" << endl;
	}
	
	
	
	return 0;
}