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

using namespace std;


int main() {
    int n;
    cin >> n;
    if (n < 18) {
        cout << "NIE" << endl;
        return 0;
    }
    int tab[15] { 0 };
    while (n-- > 0) {
        string s;
        cin >> s;
        int v = (s.at(1)-'A')*5 + s.at(0) - '1';
        //cout << s << " - " << v << endl;
        tab[v]++;
    }
    bool ok = true;
    for ( int x : tab) ok = ok && x >= 1; // kazde min 1x
    ok = ok && tab[4] >= 2 && tab[9] >= 2 && tab[14] >= 2; //5A,5B,5C min 2x
    cout << (ok ? "TAK":"NIE"  ) << endl;
}