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
#include <bits/stdc++.h>
using namespace std;

bool isPrime(long long x) {
    if(x == 1)
        return false;

    for(int i = 2; 1LL * i * i <= x; ++i) {
        if(x % i == 0)
            return false;
    }
    return true;
}

long long getLong(string s) {
    int n = s.size();
    long long ans = 0;
    if(s[0] == '0')
        return 1LL;
    for(int i = 0; i < n; ++i) {
        ans = 10LL * ans + s[i] - '0';
    }
    return ans;
}

int main() {
    string s; cin >> s;
    int len = s.size();

    for(int i = 1; i < len; ++i) {
        long long a = getLong(s.substr(0, i));
        long long b = getLong(s.substr(i));
        if(isPrime(a) and isPrime(b)) {
            cout << "TAK\n";
            return 0;
        }
    }

    cout << "NIE\n";
}