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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <cstdio>
#include <cmath>

long long dec[14] = { 1,
                      10,
					  100,
					  1000,
					  10000,
					  100000,
					  1000000,
					  10000000,
                      100000000,
					  1000000000,
					  10000000000,
					  100000000000,
					  1000000000000,
					  10000000000000};

bool isPrime(long long num) {
    if(num == 0 || num == 1) {
	    return false;
	}
	if(num == 2 || num == 3) {
	    return true;
	}
	int sqrt_ = sqrt(num + 1) + 1;
	for(int divider=2; divider<sqrt_; ++divider) {
		if(num % divider == 0) {
            return false;
		}
	}
	return true;
}

long long getNum(int number[], int begin, int end) {
	long long num = 0;
	for(int size = end - begin; begin != end; ++begin, --size) {
		num += number[begin] * dec[size-1];
	}
	return num;
}

/*void getNumTest() {
	int size = 5;
	int num[size] = {5,6,7,8,9};
	int begin = 2;
	int end = 5;
	
	printf("Test: %lld\n", getNum(num, begin, end));
}*/

bool getNextPair(int number[], int size, int& pos, long long& num1, long long& num2) {
    while(pos < size) {
		if(number[pos] == 0) {
			++pos;
			continue;
		}
		num1 = getNum(number, 0, pos);
		num2 = getNum(number, pos, size);
        return true;
	}
	return false;
}

/*void getNextPairTest() {
    int size = 5;
	int num[size] = {5,6,7,8,9};
	int pos = 2;
	
	long long num1, num2;
	getNextPair(num, size, pos, num1, num2);
	
	printf("Test: %lld, %lld\n", num1, num2);
}*/

/*void getNextPairTest1() {
    int size = 6;
	int num[size] = {1,0,0,1,0,0};
	int pos = 1;
	
	long long num1, num2;
	getNextPair(num, size, pos, num1, num2);
	
	printf("Test: %lld, %lld\n", num1, num2);
}*/

bool consistsOf2Primes(int number[], int size) {
	int pos = 1;
	long long num1, num2;
	while(size > pos) {
        if(getNextPair(number, size, pos, num1, num2)) {
			if(isPrime(num1) && isPrime(num2)) {
				return true;
			}
			++pos;
		} else {
			break;
		}
	}
	return false;
}

int main() {
	char number[15];
	int num[15];
	int i = 0;
	scanf("%s", number);
	while(number[i] != '\0') {
		num[i] = number[i]-48;
		++i;
	}
	if(consistsOf2Primes(num, i)) {
		printf("TAK\n");
	} else {
		printf("NIE\n");
	}
	return 0;
}