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
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define FOR(name, j)  for(int name = 0; name <  (j); name++)
#define MAX(a,b)      ((a) > (b) ? (a) : (b))
#define MIN(a,b) 	  ((a) < (b) ? (a) : (b))
#define checkbit(n,b) ((n >> b) & 1)
#define INF           (int)1e9
#define ll 			  long long

using namespace std;

bool isEven(int n) {
	return (n & 1) == 0;
}

bool isOdd(int n) {
	return !isEven(n);
}

int letterToIndex(char c) {
	return c - 'a';
}

int* createLetterCounter() {
	int* counter = new int[26];

	for(int i = 0; i < 26; i++) {
		counter[i] = 0;
	}

	return counter;
}

int* countEven(const vector<char> *vec) {
	int* counter = createLetterCounter();

	for(int i = 0; i < vec->size(); i++) {
		if(isEven(i)) {
			char letter = vec->at(i);
			int index = letterToIndex(letter);
			counter[index]++;
		}
	}
	
	return counter;
} 

int* countOdd(const vector<char> *vec) {
	int* counter = createLetterCounter();

	for(int i = 0; i < vec->size(); i++) {
		if(isOdd(i)) {
			char letter = vec->at(i);
			int index = letterToIndex(letter);
			counter[index]++;
		}
	}
	
	return counter;
} 

bool areEqual(const int *counter1, const int *counter2) {
	for(int i = 0; i < 26; i++) {
		if(counter1[i] != counter2[i]) {
			return false;
		}
	}
	return true;
}

vector<char>* loadCharacters(int n) {
	vector<char>* chars = new vector<char>(n);
	
	for(int i = 0; i < n; i++) {
		char c;
		scanf(" %c", &c);
		chars->at(i) = c;
	}

	return chars;
}

int main() {

	int n;
	scanf("%i", &n);
	vector<char>* first = loadCharacters(n);
	vector<char>* second = loadCharacters(n);

	int* even1 = countEven(first);
	int* even2 = countEven(second);

	int* odd1 = countOdd(first);
	int* odd2 = countOdd(second);

	bool areEvenEqual = areEqual(even1, even2);
	bool areOddEqual = areEqual(odd1, odd2);

	if(areEvenEqual && areOddEqual) {
		printf("TAK\n");
	} else {
		printf("NIE\n");
	}

	return 0;
}