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

using namespace std;

bool isPrime(long long int number) {
    if (number == 1 || number == 0) return false;
    if (number <= 3) return true;
    for (int i = 2; i < sqrt(number); i++) {
        if (number % i == 0) return false;
    }
    return true;

}

int main() {
    string number;
    cin >> number;

    bool isSecond = false;
    for (unsigned int i = 1; i < number.length(); i++) {
        string a = number.substr(0, i);
        string b = number.substr(i, number.length());
        if (a[0] == '0' || a[a.length() - 1] == '0' || b[0] == '0' || b[b.length() - 1] == '0') {
            cout << "NIE";
            return 0;
        }

        if (isPrime(stoll(a)) && isPrime(stoll(b))) {
            isSecond = true;
            break;
        } else {
            isSecond = false;
        }
    }

    if (isSecond) {
        cout << "TAK";
    } else {
        cout << "NIE";
    }


    return 0;
}