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

using namespace std;

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

	vector<vector<int>> round(5, vector<int>(3, 0));
	char a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (b == 'A') round[a - '0' - 1][0]++;
		if (b == 'B') round[a - '0' - 1][1]++;
		if (b == 'C') round[a - '0' - 1][2]++;
	}
	bool ok = true;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			if (round[i][j] == 0) ok = false;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (round[4][i] <= 1) ok = false;
	}

	if (ok) cout << "TAK\n";
	else cout << "NIE\n";

	return 0;
}