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
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

const int N = 64;
const int L = 2000000000;
long long fib[N];
int n;

void findFibs() {
  fib[0] = 0;
  fib[1] = 1;
  n = 0;
  for (int i = 2; fib[i - 1] < L; ++i) {
    fib[i] = fib[i - 2] + fib[i - 1];
    n = i + 1;
  }
}

inline bool isFib(long long v) {
  return binary_search(fib, fib + n, v);
}

inline bool checkFib(long long v) {
  if (v < 4) return true;
  for (int i = 1; fib[i] < v; ++i) {
    if (!(v % fib[i]) && isFib(v / fib[i])) return true;
  }
  return false;
}

int main() {
  findFibs();
  int t;
  scanf("%d", &t);
  while (t--) {
    int v;
    scanf("%d", &v);
    printf("%s\n", checkFib(v) ? "TAK" : "NIE");
  }

  return 0;
}