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

bool isFirst(long long n)
{
    if(n<2)
        return false;
    if(n == 2)
        return true;
    if(n%2 == 0)
        return false;
    for(long long i=3; i*i<=n; i+=2)
        if(n%i == 0)
            return false;
    return true;
}

int main()
{
    long long n;
    cin >> n;
    int d = 10;
    while(n/d>0)
    {
        long long a = n/d;
        long long b = n%d;
        if(b<(d/10))
        {
            d *= 10;
            continue;
        }
        if(isFirst(a) && isFirst(b))
        {
            cout << "TAK";
            return 0;
        }
        d *= 10;
    }
    cout << "NIE";
}