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
86
87
88
89
90
91
#include <cctype>
#include <iostream>
#include <vector>

using namespace std;

typedef long long LL;
#define FOR(ii, ll, uu)  for(int ii##lim = (uu), ii = (ll); ii < ii##lim; ++ii)
#define REP(ii, nn) FOR(ii, 0, nn)
#define FORL(ii, ll, uu)  for(LL ii##lim = (uu), ii = (ll); ii < ii##lim; ++ii)
#define REPL(ii, nn) FOR(ii, 0, nn)

const int limit = 2750000;
char buf[limit];

int main(int argc, char const *argv[])
{
    int len;
    cin >> len;
    while(cin.get() != '\n');
    // vector<char> buf(limit);

    // blind hope...
    if (len == 0)
    {
        REP(i, limit)
        {
            int c = cin.get();
            if (!cin || isspace(c) || c == EOF) 
            {
                len = i;
                break;
            }
            buf[i] = c;
        }
        if (len == 0)
        {
            // BAD LUCK
            cout << "NIE" << endl;
            return 0;
        }
    }
    else if (len <= limit)
    {
        REP(i, len)
        {
            cin >> buf[i];
        }
    }
    else if (len <= 2 * limit + 1)
    {
        int l2 = len / 2;
        REP(i, l2)
        {
            cin >> buf[i];
        }
        char c;
        if (len % 2)
        {            
            cin >> c;
        }
        REP(i, l2)
        {
            cin >> c;
            if (c != buf[l2-1-i])
            {
                cout << "NIE" << endl;
                return 0;
            }
        }
        cout << "TAK" << endl;
        return 0;
    }
    else
    {
        cout << "NIE" << endl;
        return 0;
    }

    for (int i=0, j=len-1; i <= j; ++i, --j)
    {
        if (buf[i] != buf[j])
        {
            cout << "NIE" << endl;
            return 0;
        }
    }

    cout << "TAK" << endl;
    return 0;
}