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
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

bool is_prime(ll n) {
    if (n < 2) return 0;
    for (ll d = 2; d*d <= n; ++d) {
        if(n % d == 0) return 0;
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    vector<int> digits;
    for (int i = 0; i < s.size(); ++i) {
        digits.pb(s[i]-'0');
    }
    for (int pos = 0; pos < digits.size()-1; ++pos) {
        if (digits[pos+1] == 0) continue;
        ll n = 0;
        for (int i = 0; i <= pos; ++i) {
            n = 10*n + digits[i];
        }
        ll m = 0;
        for (int i = pos+1; i < digits.size(); ++i) {
            m = 10*m + digits[i];
        }
        if (is_prime(n) and is_prime(m)) {
            cout << "TAK" << endl;
            return 0;
        }
    }
    cout << "NIE" << endl;

    return 0;
}