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

bool isPrime(long long x) {
   if(x < 2) return false;
   for(long long i = 2; i * i <= x; i++) {
      if(x % i == 0) return false;
   }
   return true;
}

bool isDoublePrime(long x) {
   long long mask = 1000000000000L;
   for(int i = 1; i < 13; i++) {
      long long left = x / mask;
      long long right = x % mask;
      mask /= 10;
      if(x % mask == right) continue;
      if(isPrime(left) && isPrime(right)) return true;
   }
   return false;
}

int main() {
   long long x;
   scanf("%ld", &x);
   printf(isDoublePrime(x) ? "TAK\n" : "NIE\n");
   return 0;
}