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
53
54
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;



public class ilo {
    public static void main(String[] args) throws IOException {
    	boolean[] isFibsProduct = new boolean[1000*1001];
    	for(int i = 0; i < isFibsProduct.length; i++) {
    		isFibsProduct[i] = false;
    	}
    	
    	long[] fib = new long[1000];
    	int fibsCnt = 2;
    	fib[0] = 0;
    	fib[1] = 1;
    	
    	while(fib[fibsCnt-1] <= 1000*1000) {
    		fib[fibsCnt] = fib[fibsCnt-2] + fib[fibsCnt-1];
    		fibsCnt++;
    	}
    	
    	for(int i = 0; i < fibsCnt; i++) {
    		for(int j = 0; j < fibsCnt; j++) {
    			if(fib[i] * fib[j] < isFibsProduct.length) {
    				isFibsProduct[(int) (fib[i] * fib[j])] = true;
    			}
    		}
    	}
    	
    	
    	
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer;

        tokenizer = new StringTokenizer(reader.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());

        for(int i = 0; i < n; i++) {
        	tokenizer = new StringTokenizer(reader.readLine());
        	int input = Integer.parseInt(tokenizer.nextToken());
            System.out.println(isFibsProduct[input] ? "TAK" : "NIE");
        }

    	/*for(int i = 0; i < fibsCnt; i++) {
    		System.out.print(fib[i] + "  ");
    	}
    	System.out.println(fibsCnt);*/
    	
        return;
    }
}