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

const int MIN_VAL = 0;
const int MAX_VAL = 1000 * 1000 * 1000 + 1;

int z, n;
int minW, maxW, minH, maxH;
bool isMajor;

struct company 
{
	int w1;
	int w2;
	int h1;
	int h2;
};

company offers[100010];

int main()
{
	scanf("%d", &z);
	while(z--)
	{
		minW = MAX_VAL;
		minH = MAX_VAL;
		maxW = MIN_VAL;
		maxH = MIN_VAL;
		isMajor = false;
		
		scanf("%d", &n);
		for(int i = 0; i < n; i++)
		{
			scanf("%d%d%d%d", &offers[i].w1, &offers[i].w2, &offers[i].h1, &offers[i].h2);
			minW = min(minW, offers[i].w1);
			minH = min(minH, offers[i].h1);
			maxW = max(maxW, offers[i].w2);
			maxH = max(maxH, offers[i].h2);
		}
		for(int i = 0; i < n; i++)
		{
			if(offers[i].w1 == minW && offers[i].w2 == maxW && offers[i].h1 == minH && offers[i].h2 == maxH)
			{
				isMajor = true;
				break;
			}
		}
		
		if(isMajor == true)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
	return 0;
}