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
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int manx = 1000110;
int  n, k, z,  x, it;
int p[manx];
int l[140];
bool t[manx];

long long fir, sec;

string s;

void sito()
{
    for(int i = 2; i <= 1000; i++)
    {
        if(!t[i])
        {
            t[i] = true;
            p[it] = i;
            it++;
            for(int k = i*i; k <= 1000000; k+=i)
            {
                t[i] = false;
            }
        }
    }
    for(int i = 49; i <= 57; i++) l[i] = i-48;
}

bool check(long long a, long long b)
{
    for(int i = 0; i < it; i++)
    {
        if(p[i] > sqrt(a)) break;
        if(a%p[i] == 0) return false;
    }
    for(int i = 0; i < it; i++)
    {
        if(p[i] > sqrt(b)) break;
        if(b%p[i] == 0) return false;
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    it = 0;
    sito();
    cin >> s;
    fir = 0;
    sec = 0;
    for(int i = 0; i < s.size(); i++)
    {
        sec += l[s[i]]*pow(10, s.size()-i-1);
    }
    //cout << sec << endl;;
    for(int i = 0; i < s.size()-1; i++)
    {
        fir = fir*10 + l[s[i]];
        sec -= l[s[i]]*pow(10, s.size()-i-1);
       // cout << fir << " " << sec << endl;
       if(check(fir, sec) && l[s[i+1]]!=0)
       {
        cout << "TAK";
        return 0;
       }
    }
    cout << "NIE";


}