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

using namespace std;

list<int> fib;

void prepare() {
  fib.push_back(0);
  fib.push_back(1);
  int tab[3];
  tab[0] = 0; tab[1] = 1; tab[2] = 0;
  int f = 0;
  int cnt = 0;
  while (f < 1000000000) {
    f = tab[(cnt+2)%3] = tab[(cnt)%3] + tab[(cnt+1)%3];
    ++cnt;
    fib.push_back(f);
  }
  fib.pop_back();
}

bool test(int x) {
  if (x < 4) return true;
  
  for (list<int>::const_iterator i = fib.begin(); i != fib.end(); ++i) {
    for (list<int>::const_iterator j = i; j != fib.end(); ++j) {
      if (((*i) * (*j) == x) ) return true;
    }
  }

  return false;
}

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

  for (int i = 0; i < t; ++i) {
    int x;
    cin >> x;
    cout << (test(x) ? "TAK" : "NIE") << endl;
  }

}