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
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class ilo {
	
	private static final int MAX_INPUT_VALUE = 1000000000;
	
	private Set<Long> products = new HashSet<Long>();
	
	
	public static void main(String[] args) {
		ilo iloczyn = new ilo();
		iloczyn.prepare();
		iloczyn.proceed();
	}

	private void prepare() {
		long[] fiboNumbers = new long[50];
		fiboNumbers[0] = 0;
		fiboNumbers[1] = 1;
		int i = 2;
		do {
			fiboNumbers[i] = fiboNumbers[i-1] + fiboNumbers[i-2];
		} while (fiboNumbers[i++] <= MAX_INPUT_VALUE);
		for (int k = 0; k < fiboNumbers.length; k++) {
			for (int j = k; j < fiboNumbers.length; j++) {
				long product = fiboNumbers[k] * fiboNumbers[j];
				if (product <= MAX_INPUT_VALUE) {
					products.add(product);
				} else {
					break;
				}
			}
		}
	}
	
	private void proceed() {
		Scanner scanner = new Scanner(System.in);
		int inputsCount = scanner.nextInt();
		for (int i = 0; i < inputsCount; i++) {
			Long input = scanner.nextLong();
			System.out.println(products.contains(input) ? "TAK" : "NIE");
		}
		scanner.close();
	}

}