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
#include<bits/stdc++.h>
using namespace std;

using LL = long long;

bool p(LL n)
{
	for(long long i = 2; i * i <= n; i++)
		if(n % i == 0) return 0;
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	LL a;
	cin >> a;
	LL b = 0;
	LL k = 1;
	while(a >= 10)
	{
		bool xd = 1;
		if((a % 10) == 0) xd = 0;
		b += (a % 10) * k;
		k *= 10;
		a /= 10;
		if(xd && p(a) && p(b)) 
			{cout << "TAK\n"; return 0;}
	}
	cout << "NIE\n";
	return 0;
}