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
#include <iostream>
#include <cmath>

using namespace std;

bool czyPierwsza(long long a) {
	if (a == 1) return false;
	if (a == 2) return true;
	if (a % 2 == 0) return false;
	for (int i = 3; i < a; i += 2) {
		if (a % i == 0) {
			return false;
		}
	}
	return true;
}

bool czyDruga(long long a) {
	int n = log10(a) + 1;
	for (int i = 1; i < n; i++) {
		long long x = a % (long long)(pow(10, i));
		long long y = a / (long long)(pow(10, i));
		if ((long long)(log10(x) + 1) == i && (long long)(log10(y) + 1) == n - i && czyPierwsza(x) && czyPierwsza(y))
			return true;
	}
	return false;
}

int main() {
	long long n;
	cin >> n;
	cout << (czyDruga(n) ? "TAK" : "NIE");
	return 0;
}