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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector <string> dane;
int a[6], b[6], c[6], n, uzyte;
string porownywane, typ = "A", numer, l;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> l;
		dane.push_back(l);
	}
	for (int i = 1; i <= 6; i++)
	{
		numer = to_string(i);
		if (numer == "6") numer = "5";
		porownywane = numer + typ;
		for (int u = 0; u < n; u++)
		{
			if (porownywane == dane[u] && u != uzyte)
			{
				a[i - 1] = 1;
				if (i == 5) uzyte = u;
			}
		}
	}
	typ = "B";
	uzyte = -1;
	for (int i = 1; i <= 6; i++)
	{
		numer = to_string(i);
		if (numer == "6") numer = "5";
		porownywane = numer + typ;
		for (int u = 0; u < n; u++)
		{
			if (porownywane == dane[u] && u != uzyte)
			{
				b[i - 1] = 1;
				if (i == 5) uzyte = u;
			}
		}
	}
	typ = "C";
	uzyte = -1;
	for (int i = 1; i <= 6; i++)
	{
		numer = to_string(i);
		if (numer == "6") numer = "5";
		porownywane = numer + typ;
		for (int u = 0; u < n; u++)
		{
			if (porownywane == dane[u] && u != uzyte)
			{
				c[i - 1] = 1;
				if (i == 5) uzyte = u;
			}
		}
	}
	if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 1 && b[0] == 1 && b[1] == 1 && b[2] == 1 && b[3] == 1 && b[4] == 1 && b[5] == 1 && c[0] == 1 && c[1] == 1 && c[2] == 1 && c[3] == 1 && c[4] == 1 && c[5] == 1)
	{
		cout << "TAK";
	}
	else cout << "NIE";

	return 0;
}