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
#include <iostream>

#define FOR(i, x) for(int i = 0; i < x; ++i)

using namespace std;

bool zadania[6][3];

int main() {
    int n;
    int ile = 0;
    string z;

    cin >> n;
    FOR(i, n) {
        cin >> z;
        if(!zadania[z[0]-49][z[1] - 65]) {
            zadania[z[0]-49][z[1] - 65] =  true;
            ile++;
            if(ile == 18) {
                cout << "TAK";
                return 0;
            }
        } else if(z[0]-49 == 4 && !zadania[5][z[1] - 65]) {
            zadania[5][z[1] - 65] =  true;
            ile++;
            if(ile == 18) {
                cout << "TAK";
                return 0;
            }
        }
    }
    cout << "NIE";
    return 0;
}