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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import java.io.*;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;

public class ilo {

    private static final boolean LOCAL = false;

    private final static long MAX_N = 10000000;

    private Set<Long> fib = new HashSet<>();

    private void solve() throws IOException {
        prepareFib();
        int t = nextInt();
        for (int i = 0; i < t; i++) {
            solveOne();
        }
    }

    private void prepareFib() {
        long a = 0;
        long b = 1;
        fib.add(a);
        fib.add(b);
        while (b <= MAX_N) {
            long c = a + b;
            a = b;
            b = c;
            fib.add(c);
        }
    }

    private void solveOne() throws IOException {
        long n = nextLong();
        for (Long x : fib) {
            for (Long y : fib) {
                if (x * y == n) {
                    out.println("TAK");
                    return;
                }
            }
        }
        out.println("NIE");
    }

    // ----------------- HELPER ROUTINES ------------------

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer strTok;

    private String nextLine() throws IOException {
        return in.readLine();
    }

    private String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            String line = nextLine();
            if (line != null) {
                strTok = new StringTokenizer(line);
            } else {
                return null;
            }
        }
        return strTok.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private BigInteger nextBig() throws IOException {
        return new BigInteger(nextToken());
    }

    public static void main(String[] args) {
        new ilo().run();
    }

    private long getMemory() {
        return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;
    }

    private void run() {
        try {
            if (LOCAL) {
                runLocal();
            } else {
                runContest();
            }
            System.exit(0);
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(42);
        }
    }

    private void runContest() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    private void runLocal() throws IOException {
        Locale.setDefault(Locale.US);
        in = new BufferedReader(new FileReader("src/input.txt"));
        out = new PrintWriter("src/output.txt");
        long startMem = getMemory();
        long startTime = System.currentTimeMillis();
        solve();
        out.flush();
        long endTime = System.currentTimeMillis();
        long endMem = getMemory();
        System.out.println("Running time = " + (endTime - startTime) + "ms");
        System.out.println("Memory used = " + (endMem - startMem) + "MB");
        System.out.println("Total memory = " + getMemory() + "MB");
    }

}