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

bool is_prime(long long x) {
    if (x < 2)
        return false;
    if (!(x % 2))
        return x == 2;
    for (int i = 3; i * i <= x; i += 2)
        if (!(x % i))
            return false;
    return true;
}

int main() {
    long long n;
    std::cin >> n;
    const std::string &n_str = std::to_string(n);
    unsigned long n_len = n_str.length();
    for (unsigned i = 1; i < n_len; i++) {
        const std::string &left = n_str.substr(0, i);
        const std::string &right = n_str.substr(i, n_len);
        if (left[0] == '0' || right[0] == '0')
            continue;
        if (is_prime(std::stoll(left)) && is_prime(std::stoll(right))) {
            std::cout << "TAK" << std::endl;
            return 0;
        }
        
    }
    std::cout << "NIE" << std::endl;
    return 0;
}