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
package com.company;

import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ilo {

    private List<Integer> fibonacciList;

    public ilo() {
        fibonacciList = generateFibonacciList();
    }

    private List<Integer> generateFibonacciList() {
        List<Integer> list = new ArrayList<Integer>(45);
        list.add(1);
        list.add(1);
        for (int i = 2; i < 45; i++) {
            list.add(list.get(i - 2) + list.get(i - 1));
        }
        return list;
    }

    public static void main(String[] args) {
        ilo main = new ilo();
        Scanner stdin = new Scanner(new BufferedInputStream(System.in));
        int loops = stdin.nextInt();
        List<Integer> input = new ArrayList<Integer>(loops);
        for (int i = 0; i < loops; i++) {
            input.add(i, stdin.nextInt());
        }

        for (Integer integer : input) {
            main.checkNumber(integer);
        }
    }

    private void checkNumber(int i) {
        for (Integer integer : fibonacciList) {
            if (integer > i)
                break;

            if (i % integer == 0 && fibonacciList.contains(i / integer)) {
                System.out.println("TAK");
                return;
            }
        }
        System.out.println("NIE");
    }
}