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
#include <iostream>
#include <vector>
#include "math.h"

using namespace std;
typedef long long int int64;

int64 n;
vector< int > primes;

void calc_primes()
{
	int sqrtn = (int)sqrt(n)+1;
	//cout << sqrtn << ": ";
	vector<bool> p(sqrtn+1, true);
	primes.reserve(sqrtn);
	int64 i = 2;
	while ( i <= sqrtn )
	{
		if(p[i])
		{
	  	primes.push_back( i );
	  	//cout << i << " ";
	  	int64 j = i * i;
		  while (j<=sqrtn)
		  {
		  	p[j]=false;
		  	j+=i;
		  }
		}
		++i;
	}
}

bool is_prime( int64 x )
{
    const int s = primes.size();
    int i=0;
    while (1)
    {
    	int64 prime=primes[i];
        if ( prime * prime > x)
          return true;
        if (!(x % prime))
          return false;
        ++i;
    }
    return true;
}

int main()
{
  cin >> n;
  
  calc_primes();
  
  int64 i = 1;
  while ( i * 10 < n )
  {
  	i *= 10;
  	int64 a = n / i;
  	int64 b = n - a * i;
  	if ( b * 10 < i ) continue;
  	//cout << "ab=" << a << " " << b << endl;
  	if ( !is_prime( a ) ) continue;
  	if ( !is_prime( b ) ) continue;
  	cout << "TAK";
      return 0;
  }
  cout << "NIE";
  return 0;
}