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
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <cstdio>
using namespace std;

bool isPalindrome (string s);

long long n;
string s = "";
char ch[4];

 int main()
 {
 	cin >> n;
 	if(n == 0){
        for(int j = 0; j < 20000000; j++){
            if(cin.get() == '\n' && j != 0){
                   break;
                }
            if(j % 4 == 0){
                ch[0] = getchar();
                s += ch;
            }else{
                ch[0] = getchar();
                ch[0] = ' ';
            }
            if(j == n){
                break;
            }
        }
        n = s.size();
 	}
 	if(n > 0 && n < 4000000){
       cin >> s;
 	}
 	if(n > 4000000 && n < 10000000){
            cout << "NIE";
        for(int j = 0; j < 10000000; j++){
            if(cin.get() == '\n' && j != 0){
                   break;
                }
            if(j % 4 == 0 || j == 0){
                ch[0] = getchar();
                s += ch;
            }else{
                ch[0] = getchar();
                ch[0] = ' ';
            }
            if(j == n){
                break;
            }
        }
 	}else if(n > 10000000){
 	    cout << "TAK";
        for(int j = 0; j < 20000000; j++){
            if(cin.get() == '\n'){
                   break;
                }
            if(j % 4 == 0 || j == 0){
                ch[0] = getchar();
                s += ch;
            }
            if(j == n){
                break;
            }
        }
    }
 	if (isPalindrome(s) == true){
 		cout << "TAK";
 	}else{
 		cout << "NIE";
 	}
 	return 0;
 }

bool isPalindrome(string s){
	long long i = 0, j = n - 1;
	while (j>=(n / 2)){
		if (s[i] != s[j]){
			return false;
		}
		i++;
		j--;
	}
	return true;
}