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
#include <cmath>
#include <cstdio>
#include <cstring>

typedef long long ll;
const int _MAXLOG = 14;

char N_s[_MAXLOG + 1];
ll N;

ll x = 1;
int LOG;
ll tens[_MAXLOG];

bool prime(ll x) {
    if(x < 2)
        return false;
    if(x < 4)
        return true;
    for(ll i = 2; i <= sqrt(x) + 1; i++) {
        if(x % i == 0)
            return false;
        else if(x % (x / i) == 0)
            return false;
    }

    return true;
}

int main() {
    tens[0] = 1;
    for(int i = 1; i < _MAXLOG; i++)
        tens[i] = tens[i - 1] * 10; 

    scanf(" %s", N_s);
    int l = strlen(N_s);
    for(int i = 0; i < l; i++)
        N += (N_s[i] - '0') * tens[l - i - 1];

//    printf("N : %lld\n", N);
    while(tens[LOG] <= N)
        LOG++;
    LOG--;

//    printf("LOG : %d\n", LOG);
    for(int i = 0; i < LOG; i++) {
        if(N_s[l - (LOG - i)] == '0')
            continue;
//        printf("##################\n");
//        printf("%d - %d\n", LOG - i, LOG - i);
//        printf("%lld - %lld\n", (N / tens[(LOG - i)]), N % tens[(LOG - i)]);
    
        if(prime(N / tens[(LOG - i)]) and prime(N % tens[(LOG - i)])) {
            printf("TAK\n");
            return 0;
        }
    }

    printf("NIE\n");
    return 0;
}