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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, pom1=0, pom2=0, pom3=0, pom4=0, pom5=0, pom6=0, pom7=0, pom8=0, pom9=0, pom10=0, pom11=0, pom12=0, pom13=0, pom14=0, pom15=0;
	cin >> n;
	int a = n;
	if(a == 0)
	{
		cout << "NIE";
		abort();
	}
	for(int i=0; i<n; i++)
	{
		string znak;
		cin >> znak;
		if(znak == "1A")
		{
				pom1++;
		}
		
		else if(znak == "1B")
		{
				pom2++;
		}
		
		else if(znak == "1C")
		{
				pom3++;
		}
		
		else if(znak == "2A")
		{
				pom4++;
		}
		
		else if(znak == "2B")
		{
				pom5++;
		}
		
		else if(znak == "2C")
		{
			pom6++;
		}
		
		
		else if(znak == "3A")
		{
			pom7++;
		}
		
		else if(znak == "3B")
		{
			pom8++;
		}
		
		else if(znak == "3C")
		{
			pom9++;

		}
		
		else if(znak == "4A")
		{
			pom10++;
		}
		
		else if(znak == "4B")
		{
			pom11++;
		}
		
		else if(znak == "4C")
		{
			pom12++;
			
		}
		
		else if(znak == "5A")
		{
			pom13++;
		}
		
		else if(znak == "5B")
		{
			pom14++;
		}
		
		else if(znak == "5C")
		{
			pom15++;
		}
	}
	int tab[15] = {pom1, pom2, pom3, pom4, pom5, pom6, pom7, pom8, pom9, pom10, pom11, pom12, pom13, pom14, pom15};
	sort(tab,tab+15);
	
	for(int i=0; i<15; i++)
	{
		if(tab[i] == pom13 || tab[i] == pom14 || tab[i] == pom15)
			a-=2;
		else
			a--;
	}
	if(a == 0)
		cout << "TAK";
	else if(a > 0)
		cout << "TAK";
	else if (a < 0)
		cout << "NIE";
}