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
#include <iostream>

using namespace std;

long long fib[50];

bool isDividiableByFib(int from, long long num){
	if(num == 1)return true;
	for(int x=from; x>=2; x--){
		if(num%fib[x]==0 && num/fib[x] == 1) return true;
	}
	return false;
}
bool divideByBool(long long num){
	if(num == 0 || num == 1) return true;
	for(int first=49; first>=2; first--){
		if(num%fib[first]==0){
			if(isDividiableByFib(first, num/fib[first])){
				return true;
			}
		}
	}
	return false;
}

int main(){
	int t;
	cin >> t;

	fib[0] = 1;
	fib[1] = 1;

	for (int i = 2; i < 50; ++i) {
		fib[i] = fib[i-1] + fib[i-2];
	}

	for (int i = 0; i < t; ++i) {
		long long num;
		cin >> num;
		if(divideByBool(num)){
			cout << "TAK\n";
		} else {
			cout << "NIE\n";
		}
	}
}