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
import java.util.HashSet;
import java.util.Scanner;

public class ilo {
    final static long MAX_N = 1000000000;
    static HashSet<Integer> fib = new HashSet<Integer>();
    static int fibLen;

    public static void populateFib() {
        for (int a = 1, b = 1; a < MAX_N; b = a + b, a = b - a) {
            fib.add(a);
        }
    }

    public static boolean productOfTwoFibNumbers(int n) {
        if (n == 0) {
            return true;
        }
        for (int f : fib) {
            if (n % f == 0 && fib.contains(n / f)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        populateFib();
        Scanner sc = new Scanner(System.in);
        int T = Integer.parseInt(sc.nextLine());
        for (int t = 0; t < T; t++) {
            int n = Integer.parseInt(sc.nextLine());
            System.out.println(productOfTwoFibNumbers(n) ? "TAK" : "NIE");
        }
    }
}