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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.TreeSet;
import java.util.function.IntSupplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class ilo {

	public static void main(String[] args) {
		IntSupplier fibSupplier = new IntSupplier() {

			int f_2 = 0;
			int f_1 = 1;

			@Override
			public int getAsInt() {
				int f = f_1 + f_2;
				f_2 = f_1;
				return f_1 = f;
			}

		};

		final int[] fibs = IntStream.generate(fibSupplier).limit(43).toArray();
		Collection<Integer> all = IntStream.of(fibs)
				.flatMap(value -> IntStream.of(fibs).map(operand -> operand * value))
				.boxed().collect(Collectors.toCollection(()->new TreeSet<>()));
		
		all.add(0);
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int t = Integer.parseInt(br.readLine());
			
			while (t-- > 0){
				int i = Integer.parseInt(br.readLine());
				
				if (all.contains(i))
					System.out.println("TAK");
				else
					System.out.println("NIE");
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}

		System.exit(0);
	}

}