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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	int d=0;
	string a;
	bool tmp1=true,tmp2=true;
	int b;
	cin >> a;
	string c;
	c.clear();
	if (a.size()>1)
	{
	for (int i=0;i<a.size()-1;i++)
	{
		if (a[i+1]!='0')
		{	
		for (int j=0;j<i+1;j++)
		{
			c=c+a[j];
		}
		b=atoi(c.c_str());
		c.clear();
		if (b==1) 
		{
			tmp1=false;
		}
		else if (b==2);
		else if (b%2!=0 && b!=2)
		{
			for (int j=3;j<=sqrt(b)+2;j=j+2)
			{
				
				if (b%j==0&&b!=j) 
				{
					tmp1=false;
					break;
				}	
			}	
		}
		else 
		{
			tmp1=false;
		}
		if (tmp1)
		{
		for (int j=i+1;j<a.size();j++)
		{
			c=c+a[j];
		}
		b=atoi(c.c_str());
		c.clear();
		
		if (b==1) 
		{
			tmp1=false;
		}
		else if (b==2);
		else if (b%2!=0 && b!=2)
		{
			for (int j=3;j<=sqrt(b);j=j+2)
			{
				if (b%j==0&&b!=j) 
				{
					tmp1=false;
					break;
				}	
			}	
		}
		else 
		{
		tmp1=false;	
		}
		}
		if (tmp1) 
		{
			cout << "TAK";	
			tmp2=false;
			break;
		}
		tmp1=true;
	}
}
		if (tmp2)
		{
			cout << "NIE";
		}
	
	}
	else 
	{
		cout << "NIE";
	}
}