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
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string solve(const string& s1, const string& s2) {
  vector<int> even_s1(26);
  vector<int> odd_s1(26);
  vector<int> even_s2(26);
  vector<int> odd_s2(26);

  for(int i = 0; i < s1.size(); i++) {
    if(i % 2 == 0) {
      even_s1[s1[i] - 'a']++;
    } else {
      odd_s1[s1[i] - 'a']++;
    }
  }
  for(int i = 0; i < s2.size(); i++) {
    if(i % 2 == 0) {
      even_s2[s2[i] - 'a']++;
    } else {
      odd_s2[s2[i] - 'a']++;
    }
  }
  for(int i = 0; i < 26; i++) {
    if(even_s1[i] != even_s2[i]) return "NIE";
    if(odd_s1[i] != odd_s2[i]) return "NIE";
  }
  return "TAK";
}

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  string s1, s2;
  cin >> s1;
  cin >> s2;
  cout << solve(s1, s2) << endl;

  return 0;
}