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
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

bool isPrime(long long n){
	if(n <= 1) return false;
	for(int i=2; i<=sqrt(n); i++){
		if(n % i == 0) return false;
	}
	return true;
}

int countDigits(long long n){
	long long d=1;
	int answer=0;
	while(n/d > 0){
		answer++;
		d*=10;
	}
	return answer;
}

int main(){
	long long n;
	cin >> n;
	if(n/10 > 0){
		if(n % 2 == 0){
			if(isPrime(n/10) && (n%10 == 2)) cout << "TAK\n";
			else cout << "NIE\n";
		} else {
			long long d = 10;
			bool is_prime=false;
			while(n/d > 0 && !is_prime){
				if(countDigits(n/d)+countDigits(n%d) == countDigits(n) && isPrime(n%d) && isPrime(n/d)){
					is_prime = true;
				}
				d*=10;
			}
			if(is_prime) cout << "TAK\n";
			else cout << "NIE\n";
		}
	} else cout << "NIE\n";
}