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

using namespace std;


void readIdeas(int count, vector<vector<bool>>& ideasForDiv) {
	string idea;

	for (int i = 0; i < count; ++i) {
		cin >> idea;
		int lvl = idea[0] - '0';
		int div = idea[1] - 'A';

		if (lvl == 5 && ideasForDiv[div][lvl]) {
			lvl = 6;
		}

		if (!ideasForDiv[div][lvl])
			ideasForDiv[div][lvl] = true;
	}
}

bool isComplete(vector<vector<bool>>& ideasForDiv) {
	for (int i = 0; i < ideasForDiv.size(); ++i) {
		for (int j = 1; j < ideasForDiv[0].size(); ++j) {
			if (!ideasForDiv[i][j])
				return false;
		}
	}

	return true;
}

int main() {
	int count;
	cin >> count;

	vector<vector<bool>> ideasForDiv(3, vector<bool>(7, false));
	readIdeas(count, ideasForDiv);

	if (isComplete(ideasForDiv)) {
		cout << "TAK" << endl;
	} else {
		cout << "NIE" << endl;
	}
	return 0;
}