1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    string a;
    bool f = false;
    vector<int> arr(18,0);
    cin >> n;
    for(; n>0; n--){
        cin >> a;
        arr[(a[1]-'A')*5+(a[0]-'0')-1]++;
    }
    for (int i=0; 15>i; i++) if (!arr[i]) f = true;
    if (arr[4] < 2 || arr[9] < 2 || arr[14] < 2) f = true;

    (f) ? cout << "NIE" << endl : cout << "TAK" << endl;

    return 0;
}