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

int main()
{
    int n = 0;
    std::string inputString;;
    int aiCountRound[3][5] = { 0 };
    int iRowIndex = 0;
    int iColumnIndex = 0;
    bool bDecision = false;

    std::cin >> n;
    std::cin.ignore();
    std::getline(std::cin, inputString);

    if( n < 18 )
    {
        std::cout << "NIE";
    }
    else
    {
        bDecision = true;

        int iCounterAll = n*3;

        for( int i = 0; i <= iCounterAll-3; i += 3 )
        {        
            iColumnIndex = ( inputString[ i ] - '0' ) - 1;
            iRowIndex = ( inputString[ i + 1 ] - 'A' );
            aiCountRound[ iRowIndex ][ iColumnIndex ]++;
        }

        for( int i = 0; i < 3; i++ )
        {
            for (int j = 0; j < 4; j++)
            {
                if( aiCountRound[i][j] == 0 )
                {
                    bDecision &= false;
                    break;
                }
            }
        }

        for( int i = 0; i < 3; i++ )
        {
            if( aiCountRound[i][4] < 2 )
            {
                bDecision &= false;
                break;
            }
        }

        if( bDecision )
        {
            std::cout << "TAK";
        }
        else
        {
            std::cout << "NIE";
        }
    }

    return 0;
}