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

using namespace std;

int A[6] = {};
int B[6] = {};
int C[6] = {};

bool ok(int t[])
{
    if(t[1]>=1 && t[2]>=1 && t[3] >=1 && t[4] >=1 && t[5] >=2)
        return true;
    return false;
}

int main()
{
    //freopen("in00b.in","r",stdin);
    int n; cin >> n;
    for(int i=0; i<n; ++i)
    {
        int z;
        char c;
        cin >> z >> c;
        switch(c)
        {
        case 'A':
            A[z]++;
            break;
        case 'B':
            B[z]++;
            break;
        case 'C':
            C[z]++;
            break;
        }
    }
    if(ok(A) && ok(B) && ok(C))
        cout << "TAK" << endl;
    else
        cout << "NIE" << endl;
}