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
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Scanner;

public class ilo {

    public static int MAX_FB = 100;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        BigDecimal[]fb = new BigDecimal[MAX_FB];
        fb[0] = BigDecimal.valueOf(0);
        fb[1] = BigDecimal.valueOf(1);

        for (int i = 2; i < MAX_FB; i++) {
            fb[i] = fb[i-1].add(fb[i-2]);
        }

        int t = sc.nextInt();

        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            BigDecimal bigN = BigDecimal.valueOf(n);

            boolean found = false;

       out: for (int a = 0; a < MAX_FB; a++) {
                for (int b = 0; b < MAX_FB; b++) {
                    if (bigN.equals(fb[a].multiply(fb[b]))) {
                        found = true;
                        break out;
                    }
                }
            }

            if (found) {
                pw.println("TAK");
            } else {
                pw.println("NIE");
            }
        }

        pw.flush();
        pw.close();
        sc.close();

    }
}