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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()

using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpll = vector<pll>;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    int n;
    string st;
    map<string, int> mp;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> st;
        mp[st]++;
    }
    int tmp = 0;
    for (int i = '1'; i <= '5'; i++)
    {
        if (i == '5')
            tmp++;
        for (int j = 'A'; j <= 'C'; j++)
        {
            st = "";
            st += i;
            st += j;
            if (mp[st] <= tmp)
            {
                cout << "NIE";
                return 0;
            }
        }
    }
    cout << "TAK";
}