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
#include <iostream>
#include <string>
using namespace std;

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

	int groups['5' * 'D' + 'C' + 1]{};
	string issue;

	for (int issueCount = 1; issueCount <= count; issueCount++)
	{
		cin >> issue;
		groups[issue[0] * 'D' + issue[1]]++;
	}

	for (int round = '1'; round <= '4'; round++)
		for (int division = 'A'; division <= 'C'; division++)
			if (groups[round * 'D' + division] < 1)
			{
				cout << "NIE";
				return 0;
			}

	for (int division = 'A'; division <= 'C'; division++)
			if (groups['5' * 'D' + division] < 2)
			{
				cout << "NIE";
				return 0;
			}

	cout << "TAK";
	return 0;
}