1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <algorithm>
#include <iostream>
#include <string>

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int tasks[15] {};
	for (int i = 12; i < 15; i++) {
		tasks[i] = 1;
	}
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		tasks[(s[0] - '1') * 3 + s[1] - 'A']--;
	}
	std::cout << (std::all_of(std::begin(tasks), std::end(tasks), [](int c) {
		return c < 0;
	}) ? "TAK\n" : "NIE\n");
	return 0;
}