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
#include <bits/stdc++.h>
using namespace std;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tab[5][3];
    for(int i = 0; i < 5; i ++) {
        for(int k = 0; k < 3; k ++) tab[i][k] = 0;
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        char x, y;
        cin >> x >> y;
        tab[int(x) - int('1')][int(y) - int('A')] ++;
    }
    bool mozna = true;
    for(int i = 0; i < 4; i ++) {
        for(int k = 0; k < 3; k ++) {
            if(tab[i][k] < 1) mozna = false;
        }
    }
    for(int i = 0; i < 3; i ++) {
        if(tab[4][i] < 2) mozna = false;
    }
    if(mozna) cout << "TAK";
    else cout << "NIE";
    return 0;
}