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
#include <iostream>   
#include <string>
using namespace std;
void solve()
{
    int n, A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, B1 = 0, B2 = 0, B3 = 0, B4 = 0, B5 = 0, C1 = 0, C2 = 0, C3 = 0, C4 = 0, C5 = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string b;
        cin >> b;
        if (b == "1A") A1++;
        if (b == "2A") A2++;
        if (b == "3A") A3++;
        if (b == "4A") A4++;
        if (b == "5A") A5++;
        if (b == "1B") B1++;
        if (b == "2B") B2++;
        if (b == "3B") B3++;
        if (b == "4B") B4++;
        if (b == "5B") B5++;
        if (b == "1C") C1++;
        if (b == "2C") C2++;
        if (b == "3C") C3++;
        if (b == "4C") C4++;
        if (b == "5C") C5++;
    }
    if (n < 18) cout << "NIE";
    else
    {
        if (A1 >= 1 && A2 >= 1 && A3 >= 1 && A4 >= 1 && A5 >= 2 && B1 >= 1 && B2 > 0 && B3 > 0 && B4 > 0 && B5 > 1 && C1 > 0 && C2 > 0 && C3 > 0 && C4 > 0 && C5 > 1) cout << "TAK";
        else cout << "NIE";
    }
}
   

int main()
{   
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}