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 <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<unordered_map<char, int>> xd(5);
    for (int i = 0; i < n; i++) {
        string in;
        cin >> in;
        int runda = in[0] - '0';
        char dyw = in[1];
        xd[runda-1][dyw]++;
    }
    
    bool f = 1;
    for (int i = 0; i < 4; i++) {
        if (xd[i]['A'] < 1 || xd[i]['B'] < 1 || xd[i]['C'] < 1) {
            f = 0;
            break;
        }
    }
    if (xd[4]['A'] < 2 || xd[4]['B'] < 2 || xd[4]['C'] < 2) {
        f = 0;
    }
    
    if (f) {
        cout << "TAK\n";
    } else {
        cout << "NIE\n";
    }

    return 0;
}