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
#include <vector>
#include <cstdio>

using namespace std;

typedef long long int lint;
#define MAX 1000000

int check_p(vector<lint> P,lint p)
{
int f = 1;
vector<lint>::iterator it = P.begin(); 

	while (it != P.end() && *it < p / 2 && f == 1)
	{
		if (p % *it == 0) f = 0;			
		++it;
	}
	
	return f;
}

int main()
{
lint p,f;
vector<lint> P;
vector<lint>::iterator it;

	P.push_back(2);
	P.push_back(3);

	scanf("%lld",&p);
	f = 5;
 	while (f < p)
	{
		if (check_p(P,f)) P.push_back(f);
		f += 2;
	}

	f = 10;
	while (p > f)
	{
		if (check_p(P,p / f) && p % f > f / 10 && check_p(P,p % f)) {printf("TAK\n"); return 0;}
		f *= 10;
	}
	
//	printf("%d\n",P.size());

//	for (it = P.begin(); it != P.end(); ++it)
//		printf("%d\n",*it);
//	scanf("%d",&p);

	printf("NIE\n");

	return 0;	
}