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
#include <stdio.h>
#include <string.h>
#include <iostream>

bool IsFirst(long long n);

long long powsTen[] = {
	1,
	10,
	100,
	1000,
	10000,
	100000,
	1000000,
	10000000,
	100000000,
	1000000000,
	10000000000,
	100000000000,
	1000000000000,
	10000000000000,
	100000000000000,
	1000000000000000,
	10000000000000000
};

int main(int argc, const char *argv[])
{
	long long n;
	std::cin >> n;
	int i = 1;
	
	do
	{
		long long l = n / powsTen[i-1] % 10;
		if (l != 0) {
			long long right = n % powsTen[i];		
			long long left = (n - right) / powsTen[i];

			if (IsFirst(left) && IsFirst(right))
			{
				std::cout << "TAK";
				return 0;
			}
		}	
		i++;

	} while (n / powsTen[i] > 0);

	std::cout << "NIE";
	return 0;
}

bool IsFirst(long long n)
{
	if (n < 2) {
		return false;
	}

	for (int i=2; i*i <= n; i++){
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}