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

using namespace std;

int main()
{
    unsigned n;
    bool success = true;
    cin >> n;
    int tab[3][5] = {0};

    char first = 0;
    string zad;
    for (unsigned long long i = 0; i<n; i++) {
        cin >> zad;
        tab[zad[1]-'A'][zad[0]-'1']++;
        if(zad[1]-'A' == 0 && zad[0]-'1' == 0)
            first++;
    }
    tab[0][0]=first;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 4; j++) {
          //  cout << tab[i][j];
            if (!tab[i][j])
                success = false;
        }   
     //   cout << "|";
    }
    
    if (tab[0][4] < 2 || tab[1][4] < 2 || tab[2][4] < 2)
        success = false;
 
    if(success)
        cout << "TAK" << endl;
    else
        cout << "NIE" << endl;    
}