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
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n < 18) {
        cout << "NIE" << endl;
    } else {
        // bool done[4 * 3 + 2 * 3];
        int done[5][3] = { 0 };
        for (int i = 0; i < n; i++) {
            string s; cin >> s;
            int d = s[0] - '0';
            int o = s[1] - 'A';
            done[d - 1][o] += 1;
            // cerr << "Ustawiam " << index << "ty element na true" << endl;
        }

        bool ok = true;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                if (done[i][j] < 1 + (i == 4)) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) cout << "TAK" << endl;
        else cout << "NIE" << endl;
    }
    return 0;
}