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
//
//  main.cpp
//  wyb
//
//  Created by Wojciech Siwko on 08/12/2020.
//

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a;
    cin >> a;
    vector<string> ideas;
    for (int i = 0; i < a; i++) {
        string in;
        cin >> in;
        ideas.push_back(in);
    }
    vector<vector<int>> tasks(5, vector<int>(3, 0));
    for (string w : ideas) {
        int a = w[0]-49;
        int b = w[1]-65;
        tasks[a][b] += 1;
    }
    bool ans = true;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 3; j++) {
            if (i != 4){
                if (tasks[i][j] == 0) ans = false;
            }
            else {
                if (tasks[i][j] < 2) ans = false;
            }
        }
    }
    if (ans == true) cout << "TAK" << endl;
    else cout << "NIE" << endl;
    return 0;
}