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
//runda 2C
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

char we[500000];

int main() {
  ios_base::sync_with_stdio(0);

  int n;
  vector<char> bajP, bajN, bitP, bitN;

  bajP.reserve(200000);
  bajN.reserve(200000);
  bitP.reserve(200000);
  bitN.reserve(200000);

  cin >> n;

  cin >> we;
  for(int iN = 0; iN < n; ++iN)
    if(iN % 2)
      bajN.push_back(we[iN]);
    else
      bajP.push_back(we[iN]);

  cin >> we;
  for(int iN = 0; iN < n; ++iN)
    if(iN % 2)
      bitN.push_back(we[iN]);
    else
      bitP.push_back(we[iN]);

  sort(bajP.begin(), bajP.end());
  sort(bajN.begin(), bajN.end());
  sort(bitP.begin(), bitP.end());
  sort(bitN.begin(), bitN.end());

  if(bajP == bitP && bajN == bitN)
    cout << "TAK";
  else
    cout << "NIE";

  return 0;
}