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

bool checkIfAllTests(int tests[5][3]) {
	for (int k = 0; k < 4; k++) {
		for (int l = 0; l < 3; l++) {
			if (tests[k][l] == 0) {
				return false;
			}
		}
	}
	for (int l = 0; l < 3; l++) {
		if (tests[4][l]<2) {
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	char word[3];
	int tests[5][3] = { 0 };
	cin >> n;

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

		/*
		65 	A
		49 	1
		*/
		int testNumber = (int)(word[0]) - 49;
		int testCase = (int)(word[1]) - 65;
		tests[testNumber][testCase]++;
		
		if (checkIfAllTests(tests)) {
			cout << "TAK";
			return 0;
		}
	}
    cout << "NIE";
	return 0;
}