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
#include <bits/stdc++.h>
#define IOSTREAM_BOOST true
using namespace std;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
    os << "{";
    if (!vec.empty())
        os << vec[0];
    for (int i = 1; i < vec.size(); i++)
        os << ", " << vec[i];
    os << "}";

    return os;
}

int n;

int countt[5][3];
string str;

int main()
{
    #if IOSTREAM_BOOST
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #endif
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> str, countt[str[0] - '1'][str[1] - 'A']++;
    bool ok = true;
    for(int i = 0; i < 5; i++) for(int j = 0; j < 3; j++){
        if(i < 4){
            if(countt[i][j] < 1) ok = false;
        }
        else if(countt[i][j] < 2) ok = false;
    }
    
    cout << (ok ? "TAK\n" : "NIE\n");
    return 0;
}