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

bool A[6];
bool B[6];
bool C[6];
int main()
{
	int n;
	int chosen = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		string task;
		cin >> task;
		int num = task[0] - '1';
		if(num == 4)
		{
			if(task[1] == 'A')
			{
				if(A[4] == 1 && A[5] == 0)
				{
					chosen++;
					A[5] = 1;
				}
			}
			if(task[1] == 'B')
			{
				if(B[4] == 1 && B[5] == 0)
				{
					chosen++;
					B[5] = 1;
				}
			}
			if(task[1] == 'C')
			{
				if(C[4] == 1 && C[5] == 0)
				{
					chosen++;
					C[5] = 1;
				}
			}
		}
		if(task[1] == 'A')
		{
			if(A[num] == 0)
				chosen++;
			A[num] = 1;
		}
		if(task[1] == 'B')
		{
			if(B[num] == 0)
				chosen++;
			B[num] = 1;
		}
		if(task[1] == 'C')
		{
			if(C[num] == 0)
				chosen++;
			C[num] = 1;
		}
		if(chosen == 18)
		{
			cout <<"TAK" << endl;
			return 0;
		}
	}
	cout <<"NIE" << endl;
	return 0;
}