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 <string>

using namespace std;
using LL = long long;

bool is_prime(LL n)
{
	if (n == 1)
		return false;

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

	return true;
}

bool is_dual(string number)
{
	for (size_t i = 1; i < number.length(); i++)
	{
		string p1 = number.substr(0, i);
		string p2 = number.substr(i);

		if (p1[0] == '0' || p2[0] == '0')
			continue;

		if (is_prime(stoll(p1)) && is_prime(stoll(p2)))
			return true;
	}

	return false;
}

int main()
{
	string number;

	cin >> number;
	cout << (is_dual(number) ? "TAK" : "NIE");

	return 0;
}