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

using namespace std;
int a;
char b,c;
int tab[1000][1000];
int main()
{
    cin >> a;
    for (int i = 0; i < a; i++)
    {
        cin >> b >> c;
        tab[b][c]++;
    }
    for (int i = 0; i < 4; i++)
    {
        if (tab[i + '1']['A'] < 1 || tab[i + '1']['B'] < 1 || tab[i + '1']['C'] < 1 || tab['5']['A'] < 2 || tab['5']['B'] < 2 || tab['5']['C'] < 2)
        {
            cout << "NIE\n";
            return 0;
        }
    }
    cout << "TAK\n";
    return 0;
}