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


int n;				//Liczba danych
int division[3];	//Dywizje
char input[2];		//Wejście postaci "3A"

using namespace std;

int main()
{
	cin >> n;

	for (int i = 0; i < n; ++i) {
		cin >> input;


		division[input[1] - 65] = division[input[1] - 65] | (((5 == (input[0] - 48)) && (division[input[1] - 65] & 16))	?	(1 << 5) : (1 << (input[0] - 49)));
	}

	if (division[0] == 63 && division[1] == 63 && division[2] == 63)
		cout << "TAK" << endl;
	else
		cout << "NIE" << endl;
}