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
#include <cstdio>
#define inf 1000000005
struct Rect { int minW, minH, maxW, maxH; }; Rect Z[100010]; inline bool solve() {
	int minW = inf;
	int minH = inf;
	int maxW = 0;
	int maxH = 0;

	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &Z[i].minW, &Z[i].maxW, &Z[i].minH, &Z[i].maxH);
		if(minW > Z[i].minW)
			minW = Z[i].minW;
		if(minH > Z[i].minH)
			minH = Z[i].minH;
		if(maxW < Z[i].maxW)
			maxW = Z[i].maxW;
		if(maxH < Z[i].maxH)
			maxH = Z[i].maxH;
	}
	for(int i = 0; i < n; i++) {
		Rect r = Z[i];
		if(	   r.minH == minH && r.maxH == maxH
			&& r.minW == minW && r.maxW == maxW)
			return true;
	}
	return false;
}
int main() {
	int tests;
	scanf("%d", &tests);
	for(int i = 0; i < tests; i++)
		if(solve()) printf("TAK\n"); else printf("NIE\n");
	return 0;
}