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

using namespace std;

unsigned int min(unsigned int tablica[], int n);
unsigned int max(unsigned int tablica[], int n);

int main()
{
	ios::sync_with_stdio(0);
	short t;
	unsigned int n;
	cin >> t;	
	unsigned int minw1;
	unsigned int maxw2;
	unsigned int minh1;
	unsigned int maxh2;
	while (t != 0)	
	{
		cin >> n;
		unsigned int *w1 = new unsigned int[n];
		unsigned int *w2 = new unsigned int[n];
		unsigned int *h1 = new unsigned int[n];
		unsigned int *h2 = new unsigned int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> w1[i] >> w2[i] >> h1[i] >> h2[i];
		}
		minw1 = min(w1, n);
		maxw2 = max(w2, n);
		minh1 = min(h1, n);
		maxh2 = max(h2, n);
		for (int i = 0; i < n; i++)
		{
			if (minw1 == w1[i])
			{
				if (maxw2==w2[i])
				{
					if (minh1==h1[i])
					{
						if (maxh2 == h2[i])
						{
							cout << "TAK" << endl;
							goto tu;
						}
					}
				}
			}
		}

		cout << "NIE" << endl;	
	tu:
	    delete[]w1;
		delete[]w2;
		delete[]h1;
		delete[]h2;

		t--;
	}

	return 0;
}
unsigned int max(unsigned int tablica[],int n)
{
	unsigned int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (tablica[i]>max)
		{
			max = tablica[i];
		}
	}
	return max;
}
unsigned int min(unsigned int tablica[], int n)
{

	unsigned int min = 4294967295;
	for (int i = 0; i < n; i++)
	{
		if (tablica[i]<min)
		{
			min = tablica[i];
		}
	}
	return min;
}