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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define mor > muu & operator<<(
#define ris return *this
#define R22(r) sim>typename enable_if<1 r sizeof(dud<c>(0)),muu&>::type operator<<(c g) {
#define R23(r) sim, size_t N>typename enable_if<N r std::tuple_size<c>::value,muu&>::type operator<<(zub<c,N> 
sim> struct rge {c b, e;};
sim> rge<c> range(c i, c j) {return rge<c>{i, j};}
sim> auto dud(c*r)->decltype(cerr << *r);
sim> char dud(...);
sim, size_t N> struct zub {c x;};
struct muu {
	#ifdef LOCAL
	#define qel(t) sim, class d, class...e mor t<c,d,e...> r){ris << *(d*)&r;}
	qel(queue) qel(priority_queue) qel(stack)
	stringstream a;
	~muu() {cerr << a.str() << endl;}
	R22(<) a << boolalpha << g; ris;}
	R22(==) ris << range(begin(g), end(g));}
	sim mor rge<c> u) {
		a << "[";
		for (c i = u.b; i != u.e; ++i)
			*this << ", " + 2 * (i == u.b) << *i;
		ris << "]";
	}
	sim, class m mor pair <m,c>r){ris << "(" << r.first << ", " << r.second << ")";}
	sim, class...m mor tuple<c,m...>r){ris << zub<tuple<c,m...>,0>{r};}
	R23(!=) g) {ris << (N ? ", " : "(") << get<N>(g.x) << zub<c, N + 1>{g.x};}
	R23(==) ) {ris << ")";}
	#else
	sim mor const c&){ris;}
	#endif
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define range(a, b) "[[" #a ", " #b "): " << range(a, b) << "] "
#define debug muu() << __FUNCTION__ << "#" << __LINE__ << ": "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
using pii = pair <int, int>; using ll = long long; using ull = unsigned long long;
using ld = long double; using Pii = pii; using vpii = vector<pii>; using unt = unsigned int;
using vi = vector <int>; using pll = pair <ll, ll>; using vpll = vector <pll>;
sim> void mini(c &a, c b) {if (a > b) a = b;} sim> void maxi(c &a, c b) {if (a < b) a = b;}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
sim, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>; 

int n;
int main()
{
    scanf("%d", &n);
    map<string, int> M;
    for(int i = 0; i < n; ++i)
    {
        char buff[10];
        scanf("%s", buff);
        string str(buff);
        ++M[str];
    }
    for(int i = 1; i <= 4; ++i)
    {
        for(string s : {"A", "B", "C"})
        {
            string res = to_string(i) + s;
            if (M[res] < 1)
            {
                puts("NIE");
                return 0;
            }
        }
    }
    for(int i = 5; i <= 5; ++i)
    {
        for(string s : {"A", "B", "C"})
        {
            string res = to_string(i) + s;
            if (M[res] < 2)
            {
                puts("NIE");
                return 0;
            }
        }
    }
    puts("TAK");
}