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
55
56
57
58
59
60
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;


public class ilo {
	
	static TreeSet<Integer> fibs = new TreeSet<>();
	
	static int fib0 = 1;
	static int fib1 = 1;

	public static void main(String[] args) {
		fibs.add(1);
		
		Scanner in = new Scanner(System.in);
		
		int t = in.nextInt();
		
		int tmp;
		
		while (t-- > 0) {
			int n = in.nextInt();
			
			while (fib1 < n) {
				tmp = fib0 + fib1;
				fib0 = fib1;
				fib1 = tmp;
				
				fibs.add(fib1);
			}
			
			if (n == 0 || fibs.contains(n)) {
				System.out.println("TAK");
				continue;
			}
			
			tmp = (int) Math.sqrt(n);
			boolean b = false;

			for (Iterator<Integer> it = fibs.iterator(); it.hasNext();) {
				int x = it.next();
				
				if (x > tmp) {
					break;
				}
				
				if (n % x == 0 && fibs.contains(n / x)) {
					b = true;
					break;
				}
			}
			
			System.out.println(b ? "TAK" : "NIE");
		}
		
		in.close();
	}

}