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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
 * @author Tadeusz Faber (SI-Consulting SA).
 * 
 * Potyczki Algorytmiczne 2014.
 * 
 * 2014-05-09 Runda 0. Iloczyn. 
 *  
 * Pamiec: 128MB.
 * Czas: ?s.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public final class ilo {

	private static Reader in = null;

	/**
	 * Zwroc kolejna liczbe calkowita ze strumienia in
	 * 
	 * @return wczytana liczba
	 */
	private static int nextInteger() {

		int r = 0;
		boolean minus = false;
		char c;

		try {
			do {
				c = (char) in.read();
			} while (c == ' ' || c == '\n' || c == '\r');
			if (c == '-') {
				minus = true;
				c = (char) in.read();
			}
			do {
				r = r * 10 + (int) c - 48;
				c = (char) in.read();
			} while (c != ' ' && c != '\n' && c != '\r' && c != (char) -1);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		if (minus) {
			return -r;
		} else {
			return r;
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {

		in = new BufferedReader(new InputStreamReader(System.in));

		int max = 0;
		int t = nextInteger();
		int[] n = new int[t + 1];
		for (int i = 1; i <= t; i++) {
			n[i] = nextInteger();
			if (n[i] > max) {
				max = n[i];
			}
		}

		int x1 = 0, y1 = 1;
		while (x1 <= max) {
			int z = x1;
			x1 = y1;
			y1 = y1 + z;

			int x2 = x1, y2 = y1;
			while (x2 <= max) {
				for (int i = 1; i <= t; i++) {
					if (x1 * x2 == n[i]) {
						n[i] = 0;
					}
				}
				z = x2;
				x2 = y2;
				y2 = y2 + z;
			}
		}

		for (int i = 1; i <= t; i++) {
			if (n[i] == 0) {
				System.out.println("TAK");
			} else {
				System.out.println("NIE");
			}
		}
	}
}