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
#include <cstdio>
#include <algorithm>

const int MAXN = 100005, INF = 1000000005;
int t,n,minW,maxW,minH,maxH,data[MAXN][4];
bool answer;

int main()
{
	scanf("%d", &t);
	while(t--)
	{
		maxW = maxH = 0; minW = minH = INF; answer = false;
		scanf("%d", &n);
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%d%d%d", &data[i][0], &data[i][1], &data[i][2], &data[i][3]);
			minW = std::min(minW,data[i][0]);
			maxW = std::max(maxW,data[i][1]);
			minH = std::min(minH,data[i][2]);
			maxH = std::max(maxH,data[i][3]);
		}
		
		for(int i = 0; i < n; ++i)
			if(data[i][0] <= minW && data[i][1] >= maxW && data[i][2] <= minH && data[i][3] >= maxH)
				{ answer = true; break; }

		printf("%s\n", answer ? "TAK" : "NIE");
	}
}