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

int BI[200];
int BA[200];

int BIP[200];
int BIN[200];

int BAP[200];
int BAN[200];


int main() 
{ 

  int n, biba;
  string A, B;
  char znak;

  cin >> n;
  
  cin >> A;
  cin >> B;
  
  /*
 i=0123456
   abcdefg    BITEK
   edgbcfa    BAJTEK
  */
  
   for(int i=0; i<n; i++)
   {
     znak = A[i];
     BI[znak]++;
     
     if(i%2==0) BIP[znak]++;
     else BIN[znak]++;
   }

   for(int i=0; i<n; i++)
   {
     znak = B[i];
     BA[znak]++;

     if(i%2==0) BAP[znak]++;
     else BAN[znak]++;     
   }

   biba = 1;
   for(int i=97; i<=122; i++)
   {
     if(BI[i]!=BA[i]) { biba = 0; }
     if(BIP[i]!=BAP[i]) { biba = 0; }
     if(BIN[i]!=BAN[i]) { biba = 0; }
     
//	 cout << "literki " << i << " " << BI[i] << " " << BA[i] << "\n";
//	 cout << "parzrzyste " << i << " " << BIP[i] << " " << BAP[i] << "\n";
//	 cout << "nieparzyste " << i << " " << BIN[i] << " " << BAN[i] << "\n\n";

   }
   
   if(biba==0) { cout << "NIE"; }
   else
     { cout << "TAK"; }

			
return 0;
}