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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <cmath>
#include <map> 
#include <string> 
#include <vector> 
#include <algorithm>
#include <iostream> 
#include <cmath> 
#include <iomanip>
#include <set>
#include <unordered_set>
#define M_PI 3.14159265358979323846
#define ull  unsigned long long
#define ll   long long
#define ld   long double
#define pii  pair<int,int>
#define pll  pair<long long, long long>
#define vi   vector<int> 
#define vb   vector<bool>
#define vll  vector<long long>
#define vull vector<unsigned long long>
#define v  vector
#define vii  vector<pair<int,int>>
#define vvi  vector<vector<int>> 
using namespace std;

uint16_t arr[1350000];

inline uint16_t make_uint(char a, char b, char c) {
	return ((a - 96) << 10) + ((b - 96) << 5) + (c - 96);
}

inline uint16_t get0(uint16_t n) {
	return n >> 10;
}

inline uint16_t get1(uint16_t n) {
	return n % (1 << 10) >> 5;
}

inline uint16_t get2(uint16_t n) {
	return n % (1 << 5);
}
int main()
{
	char a,b,c;
	a = b = c = 0;
	uint32_t n = 0;
	while (cin >> a) 
	{  
		if (a >= '0' && a <= '9') continue;
		if (n % 3 == 0) {
			b = a;
		}
		else if (n % 3 == 1) {
			c = a;
		}
		else {
			arr[n / 3] = make_uint(b, c, a);
		}
			
		n++;
	}
	if (n % 3 == 1) {
		arr[n / 3] = make_uint(b, 96, 96);
	}
	else if (n % 3 == 2) {
		arr[n / 3] = make_uint(b, c, 96);
	}
	else {
	}

	n--;
	uint32_t i = 0;
	while (i <= n) {
		if (i % 3 == 0) {
			if (n % 3 == 0) {
				if (get0(arr[i / 3]) != get0(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 1) {
				if (get0(arr[i / 3]) != get1(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 2) {
				if (get0(arr[i / 3]) != get2(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
		}
		if (i % 3 == 1) {
			if (n % 3 == 0) {
				if (get1(arr[i / 3]) != get0(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 1) {
				if (get1(arr[i / 3]) != get1(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 2) {
				if (get1(arr[i / 3]) != get2(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
		}
		if (i % 3 == 2) {
			if (n % 3 == 0) {
				if (get2(arr[i / 3]) != get0(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 1) {
				if (get2(arr[i / 3]) != get1(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
			if (n % 3 == 2) {
				if (get2(arr[i / 3]) != get2(arr[n / 3])) {
					cout << "NIE"; return 0;
				}
			}
		}
		i++;
		n--;
	}
	cout << "TAK";
}