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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include<bits/stdc++.h>
using namespace std;

#define REP(i, M) for(int i = 0; i < M; i++)
#define R(p, k) for(int i = p; i <= k; i++)
#define RI(j, p, k) for(int j = p; j <= k; j++)
#define PB push_back
#define FI first
#define SE second
#define LL long long 


#define DEB 0

#if DEB
	#define CEN cerr << endl;
	#define CEL(a) cerr << #a << ": " << a << " "; 
	#define CES(s) cerr << s << endl;
#else
	#define CEN 
	#define CEL(a) 
	#define CES(s) 
#endif

unsigned LL n, pot[20];

bool isprime (unsigned LL a){
    if(a == 0 || a == 1)
        return false;
    
    for(unsigned LL i = 2; (i * i) <= a; i++)
        if(a%i == 0)
            return false;
    
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    bool ok = false;
    pot[0] = 1;
    for(int i = 1; i < 18; i++)
        pot[i] = 10 * pot[i-1];
    
    unsigned LL suf = 0;
    for(int i = 1; i < 18; i++){
        unsigned LL c = n % 10;
        suf = suf + c * pot[i - 1];
        n /= 10;
        if (c == 0)
            continue;
        
        if (n == 0)
            break;
        CES("podzial");
        CEL(n);
        CEL(suf);
        CEN;
        if(isprime(n) && isprime(suf)){
            CES("ok\n");
            ok = true;
        }
            
    }
    
    /*CEL(isprime(0));
    CEL(isprime(1));
    CEL(isprime(2));
    CEL(isprime(3));
    CEL(isprime(4));
    CEL(isprime(5));
    CEL(isprime(6));*/
    
    
    if(ok)
        cout << "TAK" << endl;
    else
        cout << "NIE" << endl;
    
    return 0;
}