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 <cstdio>

int mask[31250001];

// last: 63 245 986 (next is more than 10^9)

// 22 - last fib number which can be squared to more than 10^9

void fill_arr() {

  const int N = 38;
  int arr[N];
  int a = 1;
  int b = 1;
  for(int pos = 0; pos < N; ++pos) {
    int c = a + b;
    a = b;
    b = c;
    arr[pos] = a;
    //printf("%d\n", a);
  }
  for(int pos_a = 0; pos_a < N; ++pos_a) {
    for(int pos_b = 0; pos_b < N; ++pos_b) {
      unsigned long long x = ((unsigned long long) arr[pos_a]) * ((unsigned long long) arr[pos_b]);
      if(x > 1000000000) continue;
      mask[x / 32] |= 1 << (x % 32);
    }
  }
}

int main() {
  fill_arr();

  long long t;
  scanf("%lld", &t);
  while(t--) {
    int n;
    scanf("%d", &n);
    printf(mask[n / 32] & (1 << (n % 32)) ? "TAK\n" : "NIE\n");
  }
  return 0;
}
//5 628 750 625
//2 149 991 424