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.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class ilo {
	private static long MAX = 1000000000l;
	private static List<Long> FIB = new ArrayList<Long>();
	private static Set<Long> NUMBERS = new HashSet<Long>();
	private PrintWriter pw = null;
	private BufferedReader br = null;
	
	ilo(boolean skip) throws FileNotFoundException {
		this.pw = new PrintWriter(System.out);
		this.br = new BufferedReader(new InputStreamReader(System.in), 1 << 16);		
	}
	
	void doit() throws IllegalArgumentException, IOException {
		int N = Integer.parseInt(br.readLine());
		for (int i = 0; i < N; i++) {
			long ll = Long.parseLong(br.readLine());
			pw.println((NUMBERS.contains(ll)) ? "TAK" : "NIE");
		}
		pw.flush();
	}
	
	private static void calculateNumbers() {
		FIB.add(0l);
		FIB.add(1l);
		long number = 0;
		int position = 2;
		while (number <= MAX) {
			number = FIB.get(position - 1) + FIB.get(position - 2);
			FIB.add(number);
			position++;
		}
		FIB.remove(1);
		
		
		for (int i = 0; i < FIB.size() - 1; i++) {
			for (int j = i; j < FIB.size(); j++) {
				Long n = (long)FIB.get(i) * (long)FIB.get(j);
				if (n <= MAX) {
					NUMBERS.add(n);
				}
			}
		}
	}
	
	public static void main(String[] args) throws IllegalArgumentException, IOException {
		calculateNumbers();
		new ilo(true).doit();
	}

}