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

using namespace std;

int main()
{
    int i, j, n, zad[5][3];
    string s;

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

    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> s;
        zad[(int)s[0] - 49][(int)s[1] - 65]++;
        //cout << (int)s[0] - 49 << (int)s[1] - 65 << endl;
    }
    for (i = 0; i < 4; i++)
        for (j = 0; j < 3; j++)
            if (zad[i][j] == 0) { cout << "NIE"; return 0; }
    for (j = 0; j < 3; j++)
        if (zad[4][j] < 2) { cout << "NIE"; return 0; }

    cout << "TAK";

    return 0;
}