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
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define REP(i,n) for(int _n=(n), i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define TRACE(x) cerr << "TRACE(" #x ")" << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << endl;
typedef long long LL; typedef unsigned long long ULL;


#define BIGMOD 1000012177LL


int pomysly[256][256];

int main() {
    int n;
    scanf("%d", &n);
    char buf[10];
    REP(i,256)
      REP(j,256) pomysly[i][j] = 0;
    for (int i=0; i < n; i++)
    {
        scanf("%s", buf);
        //printf("buf=%s\n", buf);
        pomysly[buf[0]][buf[1]]++;
    }
    bool result = true;
    for (int i='1'; i <='5'; i++)
      for (int j='A'; j<='C'; j++)
        {
            if (i != '5' && pomysly[i][j] < 1)
            {
                result = false;
                break;
            }
            if (i == '5' && pomysly[i][j] < 2)
            {
                result = false;
                break;
            }
        }
    printf(result ? "TAK\n" : "NIE\n");
    return 0;
}