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

using namespace std;
typedef long long ll;

string s;


bool is_prime(ll x)
{
    if (x < 2) return false;

    for(ll i = 2; i*i <= x; i++)
    {
        if (x%i == 0)
            return false;
    }    

    return true;
}

bool ok(int i)
{
    string s1 = s.substr(0,i+1);
    string s2 = s.substr(i+1);

    if (s1[0] == '0' || s2[0] == '0')
        return false;

    stringstream ss1(s1), ss2(s2);

    ll a,b;
    ss1 >> a, ss2 >> b;

    return is_prime(a) && is_prime(b);
}

int main()
{
    ios_base::sync_with_stdio(false);


    cin >> s;

    if (s.length() < 2)
        cout << "NIE" << endl;

    for(int i = 0; i < s.length()-1; i++)
    {
        if (ok(i))
        {
            cout << "TAK" << endl;
            return 0;
        }
    }

    cout << "NIE" << endl;

    

    return 0;
}