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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ilo {

	public static void main(final String[] args) {
		final BufferedReader input =
			new BufferedReader(new InputStreamReader(System.in));
		
//		long start = 0;
		
		try {
			
			final StringTokenizer st = new StringTokenizer(input.readLine());
			final int rows = Integer.parseInt(st.nextToken());
			
			int[] numbers = new int[rows]; 
			
			for (int i = 0; i < rows; i++) {
				final StringTokenizer nd = new StringTokenizer(input.readLine());
				numbers[i] = Integer.parseInt(nd.nextToken());
			}

			for (int i = 0; i < rows; i++) {
				
				int number = numbers[i];
				int index = 0;
				Integer fibonacci = 0;
				List<Integer> fibonacciList = new ArrayList<Integer>();

				do {
					fibonacci = getFibonacci(index);
					if (number > fibonacci) {
						fibonacciList.add(fibonacci);
					} else if (number == fibonacci) { 
						break;
					} else {
						break;
					}
					index++;
				} while (number >= fibonacci); 
				
				if (number == fibonacci) {
					System.out.println("TAK");
				} else {
					checkFibonnaci(fibonacciList, number);
				}
			}
			
//			start = System.nanoTime();
			
		} catch (final NumberFormatException e) {
			System.exit(1);
		} catch (final IOException e) {
			System.exit(1);
		}
//		final long end = System.nanoTime();
//		final double time = end - start;
//		System.out.println(time/1000000000 + "s");
		System.exit(0);
	}

	
	private static void checkFibonnaci(List<Integer> fibonacciList, int number) {
		
		boolean found = false;
		
		for (int i = 0; i < fibonacciList.size(); i++) {
			for (int j = i; j < fibonacciList.size(); j++) {
				
				if (fibonacciList.get(i) * fibonacciList.get(j) == number) {
					found = true;
					break;
				}
			}
		}
		
		if (found) {
			System.out.println("TAK");
		} else {
			System.out.println("NIE");
		}
	}


	private static Integer getFibonacci(final int a) {

		if (a == 0) {
			return 0;
		}
		   
		if (a == 1) {
			return 1;
		}
		
		int f1 = 0;
		int f2 = 1;
		
		for (int i = 2; i <= a; i++) {
			int m = f1 + f2;
			f1 = f2;
			f2 = m;
		}
		
		return f2;
	}
	
}