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
//Andrzej Radzik
#include <iostream>

int main() {
	int sourceFirst[ 128 ];
	int sourceSecond[ 128 ];
	int targetFirst[ 128 ];
	int targetSecond[ 128 ];
	int n;
	int i;
	char dummy;
	bool success = true;
	
	for ( i = 'a'; i <= 'z'; i++ ) {
		sourceFirst[ i ] = 0;
		sourceSecond[ i ] = 0;
		targetFirst[ i ] = 0;
		targetSecond[ i ] = 0;
	}
	
	std::cin >> n /*>> dummy*/;
	for ( i = 0; i < n; ++i ) {
		std::cin >> dummy;
		//std::cerr << dummy << ' ';
		if ( i % 2 == 0 ) {
			sourceFirst[ dummy ] ++;
		} else {
			sourceSecond[ dummy ] ++;
		}
	}
	
	for ( i = 0; i < n; ++i ) {
		std::cin >> dummy;
		//std::cerr << dummy << ' ';
		if ( i % 2 == 0 ) {
			targetFirst[ dummy ] ++;
		} else {
			targetSecond[ dummy ] ++;
		}
	}
	
	for ( i = 'a'; i <= 'z'; ++i ) {
		if ( sourceFirst[ i ] != targetFirst[ i ] ) {
			success = false;
		}
	}
	
	for ( i = 'a'; i <= 'z'; ++i ) {
		if ( sourceSecond[ i ] != targetSecond[ i ] ) {
			success = false;
		}
	}
	
	if ( success )
		std::cout << "TAK" << std::endl;
	else
		std::cout << "NIE" << std::endl;
	
	return 0;
}