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

bool is_prime(unsigned long long x) {
    if (x <= 1) {
        return false;
    }
    for(unsigned long long i = 2; i*i <= x; ++i) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string s;
    std::cin >> s;

    for(std::uint8_t i = 1; i < s.size(); ++i) {
        auto check = [](std::string value) {
            unsigned long long as_int = std::atoll(value.c_str());

            std::ostringstream ss;
            ss << as_int;
            if (ss.str() != value) {
                return false;
            }

            return is_prime(as_int);
        };

        auto a = s.substr(0, i);
        auto b = s.substr(i);

        if (check(a) and check(b)) {
            std::cout << "TAK" << std::endl;
            return 0;
        }
    }
    std::cout << "NIE" << std::endl;
    return 0;
}