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

using namespace std;

int n;
int ile[8][8];
std::string co;
bool nie = false;
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> co;
        ile[co[0] - '1'][co[1] - 'A']++;
    }
    for (int zadanie = 0; zadanie < 4; zadanie++) {
        for (int litera = 0; litera < 3; litera++) {
            if(ile[zadanie][litera] == 0) {
                nie = true;
            }
        }
    }
    for (int litera = 0; litera < 3; litera++) {
            if(ile[4][litera] < 2) {
                nie = true;
            }
        }
    
    if (nie) {
        cout << "NIE" << endl;
    } else {
        cout << "TAK" << endl;
    }

    return 0;
}