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

using namespace std;

char bitus1[1500002];
char bitus2[1500002];
char bajtus1[1500002];
char bajtus2[1500002];

int main(){

	int n=0,lbi1=-1,lbi2=-1,lba1=-1,lba2=-1;

	cin >> n;

	for(int i=0;i<n;i++) {
		if(i%2==0) {
			lbi1++;
			cin >> bitus1[lbi1];
//			cout <<bitus1[lbi1] <<endl;
			
		} else {
			lbi2++;
			cin >> bitus2[lbi2];
//			cout << " " << bitus2[lbi2] <<endl;
			
		}
	}

	for(int i=0;i<n;i++) {
		if(i%2==0) {
			lba1++;
			cin >> bajtus1[lba1];
			
		} else {
			lba2++;
			cin >> bajtus2[lba2];
			
		}
	}

	sort(bitus1,bitus1 + lbi1+1);
	sort(bitus2,bitus2 + lbi2+1);

	sort(bajtus1,bajtus1 + lba1+1);
	sort(bajtus2,bajtus2 + lba2+1);

//	for(int i=0;i<=lbi1;i++) {
//		cout <<bitus1[i] << " " << bajtus1[i] <<endl;
//	}

	for(int i=0;i<=lbi1;i++) {
		if (bitus1[i] !=bajtus1[i]) {
			cout << "NIE" << endl;
			return 0;
		}

	}

	for(int i=0;i<=lbi2;i++) {
		if (bitus2[i] !=bajtus2[i]) {
			cout << "NIE" << endl;
			return 0;
		}

	}	
	



	cout << "TAK" <<endl;
	return 0;






}