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

constexpr auto MAXN = 20;
unsigned int pomysl[MAXN];

inline size_t get_index(unsigned char i, unsigned char c)
{
    return (static_cast<unsigned int>(c) - 65) * 5 + (static_cast<unsigned int>(i) - 49);
}

int main()
{
    unsigned int n;
    std::cin >> n;

    for (auto i = 0u; i < n; i++)
    {
        unsigned char integer, character;
        std::cin >> integer >> character;
        std::cin.get();

        pomysl[get_index(integer, character)]++;
    }

    bool ok = true;
    for (auto i = 0u; i < 15; i++)
    {
        ok &= pomysl[i] > 0;
    }
    ok &= pomysl[4] >= 2;
    ok &= pomysl[9] >= 2;
    ok &= pomysl[14] >= 2;

    std::cout << (ok ? "TAK" : "NIE") << std::endl;
}