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
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

const int HOW_MANY_ROUNDS = 18;

int main() {

   int ideas[HOW_MANY_ROUNDS]  = {
        1, 1, 1,
        1, 1, 1,
        1, 1, 1,
        1, 1, 1,
        2, 2, 2};;

   char C;
   int N;
   int X, Y;
   bool possible = true;

    cin >> N;
    for(int i = 0; i<N; i++) {
        cin >> C;
        if(C =='1') X = 0;
        if(C =='2') X = 1;
        if(C =='3') X = 2;
        if(C =='4') X = 3;
        if(C =='5') X = 4;
        cin >> C;
        if(C == 'A') Y = 0;
        if(C == 'B') Y = 1;
        if(C == 'C') Y = 2;
        ideas[(X*3) + Y]--;
    }
    for(int j = 0; j < HOW_MANY_ROUNDS; j++) {
        if(ideas[j] > 0) {
           possible = false;
        }
    }
    if(possible) {
        cout << "TAK";
    } else {
        cout << "NIE";
    }

}