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
#include <iostream>
#include <vector>
#include <set>


//
//
//
typedef long long INT;


//
// Constants
//
const INT MAX = 1000000000;


//
// Functions
//
void get_fibs(std::vector<INT> &fibs)
{
    fibs.push_back(0);
    fibs.push_back(1);

    INT a = 1;
    INT b = 1;

    for (INT i = 0; b <= MAX; ++i)
    {
        INT temp = b + a;

        a = b;
        b = temp;

        if (b <= MAX)
            fibs.push_back(temp);
    }
}


void get_products(const std::vector<INT> &fibs, std::set<INT> &products)
{
    //
    for (size_t i = 0; i < fibs.size(); ++i)
    {
        products.insert(fibs[i]);
    }

    //
    for (size_t i = 2; i < fibs.size() - 1; ++i)
    {
        for (size_t j = i; j < fibs.size(); ++j)
        {
            INT temp = fibs[i] * fibs[j];

            if (temp > MAX)
                continue;

            products.insert(temp);
        }
    }
}


int main()
{
    std::ios_base::sync_with_stdio(0);

    //
    std::vector<INT> fibs;
    get_fibs(fibs);

    //
    std::set<INT> products;
    get_products(fibs, products);

    //
    int n = 0;
    std::cin >> n;

    for (int i = 0; i < n; ++i)
    {
        INT temp = 0;
        std::cin >> temp;

        if (products.find(temp) != products.end())
        {
            std::cout << "TAK" << std::endl;
        }
        else
        {
            std::cout << "NIE" << std::endl;
        }
    }

    return 0;
}