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
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

string longToStr(unsigned long long n) {
    string str;
    stringstream strstream;
    strstream << n;
    strstream >> str;
    return str;    
}

bool isPrime(unsigned long long n) {
    if (n < 2) {
        return false;
    }
    
    if (n == 2) {
        return true;
    }
    
    if ((n & 1) == 0) {
        return false;
    }
    
    for (unsigned long long i = 3; i * i <= n; i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

bool isSecond(unsigned long long n) {
    string str = longToStr(n);
    
    for (int i = 1; i <= str.length() - 1; i++) {
        string firstNumber = str.substr(0, i);
        string secondNumber = str.substr(i);
        
        if (secondNumber.substr(0, 1) == "0") {
            continue;
        }
        
        unsigned long long first = atol(firstNumber.c_str());
        unsigned long long second = atol(secondNumber.c_str());
        if (isPrime(first) && isPrime(second)) {
            return true;
        }       
    }
    return false;
}

int main()
{
    unsigned long long n;
    cin >> n;
    
    if (isSecond(n)) {
        cout << "TAK" << endl;
    } else {
        cout << "NIE" << endl;
    }

    return 0;
}