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

bool isPrime(long v) {
    if (v <= 1)
        return false;
    else if (v <= 3)
        return true;
    else if (v%2 == 0 || v%3 == 0)
        return false;
    
    int i=5;
    while (i * i <= v) {
        if (v%i == 0 || v%(i+2) == 0)
            return false;
        i = i + 6;
    }
    return true;
}

int main(int argc, char** argv) {
    std::string n;
    std::cin >> n;
    for (int i = 1; i < n.size(); ++i) {
        std::string first = n.substr(0, i);
        std::string second = n.substr(i, n.size() - i);
        if (second.at(0) == '0') {
            continue;
        }
        if (isPrime(atol(first.c_str())) && isPrime(atol(second.c_str()))) {
            std::cout << "TAK";
            return 0;
        }
    }
    std::cout << "NIE";
    return 0;
}