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

using namespace std;

int main() {
    int ideasAmount = 0;
    cin >> ideasAmount;

    int exercises[ 5 ] [ 3 ];
    for(int i = 0; i < 5; i++)
        for (int j = 0; j < 3; j++)
            exercises[i][j] = 0;

    //filling array
    for (int i = 0; i < ideasAmount; i++) {
        string tempEx;
        cin >> tempEx;
        int divNumber = tempEx[0]-48 - 1;
        //exNumber info
        //A == 0; B == 1; C == 2
        int exNumber = tempEx[1]-65;
        exercises[divNumber][exNumber] += 1;
    }


    bool okay = true;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            if (exercises[i][j] == 0)
                okay = false;
        }
    }
    //for 5th division
    if (okay) {
        for (int i = 0; i < 3; i++)
            if (exercises[4][i] < 2)
                okay = false;
    }

    if(okay)
        cout << "TAK";
    else
        cout << "NIE";


    return 0;
}