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
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool check( unsigned long long int n )
{
    bool flag = false;
    if( n < 2 )
    {
        return false;
    }
    else if( n%2 == 0 && n > 2 )
    {
        return false;
    }
    else
    {
        for( unsigned long long int i = 3; i*i <= n; i += 2 )
        {
            if( n % i == 0 )
            {
                flag = true;
                break;
            }
        }
        if( flag == false ) return true;
        else return false;
    }

}

unsigned long long int suma_cyfr( unsigned long long int n )
{
    unsigned long long int wynik = 0;
    while( n > 0 )
    {
        wynik ++;
        n /= 10;
    }
    return wynik;
}

int main()
{
    ios_base::sync_with_stdio(0);
    unsigned long long int n;
    cin >> n;
    unsigned long long int pow = 10;
    bool flag = false;
    while( true )
    {
        if( pow > n ) break;
        unsigned long long int a = n%pow;
        unsigned long long int b = (n-a)/pow;
        if( check(a) == true && check(b) == true && (suma_cyfr(a) + suma_cyfr(b) == suma_cyfr(n)) )
        {
            //cout << b << " " << a << "\n";
            flag = true;
            break;
        }
        pow *= 10;
    }
    if( flag == true ) cout << "TAK\n";
    else cout << "NIE\n";
    return 0;
}