1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
#define fi first
#define sc second
#define forn(i,p,k) for(int i=(p);i<=(k);++i)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int T[5][3];

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    char day,div;
    cin>>n;
    forn(i,1,n)
    {
        cin>>day>>div;
        T[day-'1'][div-'A']++;
    }
    return cout<<((T[0][0]&&T[0][1]&&T[0][2]&&T[1][0]&&T[1][1]&&T[1][2]&&T[2][0]&&T[2][1]&&T[2][2]&&T[3][0]&&T[3][1]&&T[3][2]&&T[4][0]>1&&T[4][1]>1&&T[4][2]>1)?"TAK":"NIE"),0;
}