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
#include <iostream>                                                             
#include <cmath>                                                                
                                                                                
using namespace std;                                                            
                                                                                
bool prime_check(long long num){                                                
    if(num<2) return 0;                                                         

    if(num<=3) return 1;                                                        

    if(num%2==0 || num%3==0) return 0;                                          
                                                                                
                                                                                
    int lim=sqrt(num)+1;                                                        

    for(int i=5; i<=lim; i+=6)                                                  

        if(num%i==0 || num%(i+2)==0)                                            
            return 0;                                                           
    return 1;                                                                   
}                                                                               
                                                                                
string sec_num(long long n){                                                    
    long long a,b,i=10;                                                         
    do{                                                                         
        a=n/i;                                                                  
        b=n%i;                                                                  
        i*=10;                                                                  
        //cout<<a<<" "<<b<<endl;                                                
        if(b<i/100) continue;                                                   
        if(prime_check(a) && prime_check(b))                                    
            return "TAK";                                                       
                                                                                
    }while(b<a);                                                                
    return "NIE";                                                               
}                                                                               
                                                                                

int main(){                                                                     
    ios::sync_with_stdio(false);                                                
    long long n;                                                                
    cin>>n;                                                                     
    cout<<sec_num(n)<<endl;                                                     
                                                                                
    return 0;                                                                   
}