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
#include <bits/stdc++.h>

using namespace std;

int n, num[15];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s; cin >> s;
		++num[(s[0] - '1') * 3 + (s[1] - 'A')];
	}
	bool isOk = true;
	for (int i = 0; i < 12; i++)
		if (!num[i])
			isOk = false;
	for (int i = 12; i < 15; i++)
		if (num[i] < 2)
			isOk = false;
	cout << (isOk ? "TAK\n" : "NIE\n");
}