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
#include <iostream>

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

int main()
{
	long long int number;
	std::cin >> number;
	
	long front;
	long end;
	long magnitude = 1;
	
	while (number > 0) {
		front = number / 10;
		end += (number % 10) * magnitude;	
		if (isPrime(front) and isPrime(end) and (number % 10)) {
			std::cout << "TAK";
			return 0;
		}
		number /= 10;
		magnitude *= 10;
	}
	
	std::cout << "NIE";
	return 0;
}