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
57
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 1000005;
constexpr int INF = 1e9+5;
constexpr int INI = -1;


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <string> s(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];
    sort(s.begin(), s.end());
  //  for(auto u: s)
     //   cout << u << endl;
    string tab[15] = {"1A","1B","1C","2A","2B","2C","3A","3B","3C","4A","4B","4C","5A","5B","5C"};
    map <string, int> mp;
    for(int i=0; i<15; ++i){
        mp[tab[i]] = 0;
    }
    for(auto u: s){
        ++mp[u];
    }
    bool ans = true;
    for(auto u: s){
        if(u[0] != '5' && mp[u] < 1)
            ans = false;
        if(u[0] == '5' && mp[u] < 2)
            ans = false;
       // cout << mp[s[i]] << endl;
    }

    if(ans)
        cout << "TAK";
    else
        cout << "NIE";

    return 0;
}