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>
using namespace std;

const short fib_max = 50;

unsigned long* init_fib(short n){
	unsigned long* result = new unsigned long[n];
	result[0] = 0;
	result[1] = 1;
	for(short i = 2; i < n; i++){
		result[i] = result[i-1] + result[i-2];
	}
	return result;
}

bool check(unsigned long* fib, unsigned long n){
	for(short i = 0; i < fib_max; i++){
		if(fib[i] > n){
			return false;
		}
		for(short j = 0; j < fib_max; j++){
			if(fib[j] > n){
				break;
			}
			if(fib[i] * fib[j] == n){
				return true;
			}
		}
	}
	return false;
}

int main(){
	short t;
	unsigned long* fib = init_fib(fib_max);
	cin >> t;
	for(short i = 0; i < t; i++){
		unsigned long n;
		cin >> n;
		if(check(fib, n)){
			cout << "TAK"<<endl;
		}
		else{
			cout << "NIE"<<endl;
		}
	}
	return 0;
}