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

using namespace std;

int t;
long long int n;
vector<long long int> fib;
int answers[10] = {0,0,0,0,0,0,0,0,0,0};

int main() {
	cin >> t;
	for(unsigned int i = 0; i < t; i++){
		n = 0;
		fib.clear();
		fib.push_back(0);
	    fib.push_back(1);
		cin >> n;
		if(n == 0) answers[i] = 1;
		else {
			while(fib[fib.size()-1] <= n) {
				if(fib[fib.size()-1] == n || n == 1) {
					answers[i] = 1;
					break;
				}
				bool solved = false;
				for(vector<long long int>::iterator ib = fib.begin(); ib != fib.end(); ib++) {
					if((*ib * fib[fib.size()-1]) == n){
						answers[i] = 1;
						solved = true;
						break;
					}
				}
				if(solved)break;
				fib.push_back(fib[fib.size()-1] + fib[fib.size()-2]);
			}
		}
		
	}
	for(unsigned i = 0; i < t; i++){
		cout << (answers[i] == 1 ? "TAK" : "NIE") << endl;
	}
	return 0;
}