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
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cassert>
#include <vector>
#include <list>

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

uint is[15] = {};

int main()
{
	std::ios_base::sync_with_stdio(0); std::cin.tie(0);

	uint n; std::cin >> n;
	std::string s;

	for (uint i = 0; i < n; i++)
	{
		std::cin >> s;
		is[(s[0] - '1') * 3 + s[1] - 'A']++;
	}

	bool result = true;
	for (uint i = 0; i < 12; i++)
		if (is[i] <= 0)
			result = false;

	for (uint i = 12; i < 15; i++)
		if (is[i] <= 1)
			result = false;

	if (result)
		std::cout << "TAK";
	else
		std::cout << "NIE";

	return 0;
}