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 <stdio.h>

int main()
{
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; ++i)
	{
		int n;
		int wFrom, wTo, hFrom, hTo;
		int wMin = 2e9, wMax = 0, hMin = 2e9, hMax = 0;
		bool exists = false;

		scanf("%d", &n);
		for (int j = 0; j < n; ++j)
		{
			scanf("%d %d %d %d", &wFrom, &wTo, &hFrom, &hTo);
			if (wFrom < wMin)
			{
				wMin = wFrom;
				exists = false;
			}
			if (wTo > wMax)
			{
				wMax = wTo;
				exists = false;
			}
			if (hFrom < hMin)
			{
				hMin = hFrom;
				exists = false;
			}
			if (hTo > hMax)
			{
				hMax = hTo;
				exists = false;
			}

			if (wFrom == wMin && wTo == wMax && hFrom == hMin && hTo == hMax)
				exists = true;
		}
		printf("%s\n", exists ? "TAK" : "NIE");
	}
	return 0;
}