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

#define FOR(i,a,n) for (decltype(a) i = (a), i##__ = (n); i <= i##__; ++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define FORD(i,a,n) for (decltype(n) i = (a), i##__ = (n); i >= i##__; --i)
#define REPD(i,n) FORD(i,(n)-1,0)
#define ALL(x) x.begin(), x.end()
#define ALLR(x) x.rbegin(), x.rend()
#define EB emplace_back
#define ST first
#define ND second
#define OS ostream
#define OO(A) template<class... T> OS& operator<<(OS& os, const A<T...>& x) { return __o(os, ALL(x)); }
#define OD(...) OS& operator<<(OS &os, const __VA_ARGS__ &x)
#define SZ(x) ((int)x.size())
#define RS resize
#define V vector
#define nl '\n'

typedef long long LL;
typedef pair<int, int> PII;
typedef V<int> VI;
typedef V<VI> VVI;
typedef V<PII> VPII;
typedef V<VPII> VVPII;
typedef V<bool> VB;
typedef V<VB> VVB;

template<class I> OS& __o(OS&, I, I);
template<class T, size_t N> OD(array<T, N>) { return __o(os, ALL(x)); }
OO(vector) OO(deque) OO(set) OO(multiset) OO(map) OO(multimap)
template<class A, class B> OD(pair<A, B>) {
    return os << "(" << x.ST << ", " << x.ND << ")";
}
template<class I> OS& __o(OS& os, I a, I b) {
    os << "{ ";
    for (; a != b;)
        os << *a++, os << " ";
    return os << "}";
}
template<class I> OS& __d(OS& os, I a, I b) {
    os << "{\n";
    for (I c = a; a != b; ++a)
        os << "  " << distance(c, a) << ": " << *a << endl;
    return os << "}";
}
template<class... T> void __e(T&&... a) {
    int t[] = {(cerr << forward<T>(a), 0)...}; (void)t;
    cerr << endl;
}

template<class A, class B> inline void mini(A& a, B&& b) { if (b < a) a = b; }
template<class A, class B> inline void maxi(A& a, B&& b) { if (b > a) a = b; }

inline int pow2(int n) { return sizeof(int) * 8 - __builtin_clz(n); }

#ifdef DEBUG
# define D(...) __VA_ARGS__
#else
# define D(...)
#endif

#define LOG(x) D(cerr << #x ": " << x << "  ")
#define LOGN(x) D(LOG(x) << endl)
#define DUMP(x) D(cerr << #x ": ", __d(cerr, ALL(x)) << endl)
#define E(...) D(__e(__VA_ARGS__))

//end of templates

string n;

LL number(int l, int r) {
	LL x = 0, pow10 = 1;
	FOR(i, l, r)
		if(n[i] == '0')
			return -1;
		else
			break;
	FORD(i, r, l) {
		x += pow10 * (n[i] - '0');
		pow10 *= 10;
	}
	return x;
}

bool is_prime(LL x) {
	if(x < 2)
		return 0;
	for(LL i = 2; i * i <= x; ++i)
		if(x % i == 0)
			return 0;
	return 1;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	REP(i, SZ(n)-1)
		if(is_prime(number(0, i)) && is_prime(number(i+1, SZ(n)-1)))
			return cout << "TAK", 0;
	cout << "NIE";
}