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
48
49
50
51
52
53
54
55
56
57
58
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

void solveWithoutLength() {
    std::string word;
    std::getline (std::cin, word);
    int length = word.length();
    int middleLetter = length/2;
    int counter = 0;
    while(counter < middleLetter) {
        if(word.at(counter) != word.at(length - counter - 1)) {
            printf("NIE\n");
            return;
        }
        counter++;
    }
    printf("TAK\n");
}

void solveForLength(int length) {
    int middleLetter = length/2;
    int counter = 0;
    char letter;
    std::string word;
    while (counter < middleLetter) {
        scanf("%c", &letter);
        word.push_back(letter);
        counter++;
    }
    if (length % 2 == 1) {
        scanf("%c", &letter);
        counter++;
    }
    while(counter < length) {
        scanf("%c", &letter);
        counter++;
        if (letter != word.at(length - counter)) {
            printf("NIE\n");
            return;
        }
    }
    printf("TAK\n");
}

int main() {
    int wordLength;
    scanf("%d\n", &wordLength);
    if (wordLength > 0) {
        solveForLength(wordLength);
    } else {
        solveWithoutLength();
    }


    return 0;
}