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
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

bool is_prime(long long n) {
    if (n < 2) return false;
    else if (n == 2 || n == 3 || n == 5 || n == 7) return true;
    int sq = int(sqrt(n)) + 1;
    if (sq * sq > n) sq -= 1;
    if (n % 2 == 0) return false;
    for (int i = 3; i <= sq; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

void solve(string n) {
    for(int i = 1; i < n.size(); i++) {
        string beg = n.substr(0, i), end = n.substr(i);
        if (end[0] == '0') continue;
        long long a = stoll(beg), b = stoll(end);
        if (is_prime(a) && is_prime(b)) {
            cout << "TAK\n";
            return;
        }
    }
    cout << "NIE\n";
}

int main() {
    string n;
    cin >> n;
    solve(n);
    return 0;
}