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

#define N 100007

int x1[N], x2[N], y1[N], y2[N];
int xmin, xmax, ymin, ymax;
int n;

void run() {
	int i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d", &x1[i], &x2[i], &y1[i], &y2[i]);
	}
	xmin = x1[0]; xmax = x2[0]; ymin = y1[0]; ymax = y2[0];
	for (i = 0; i < n; i++) {
		if (x1[i] < xmin)
			xmin = x1[i];
		if (x2[i] > xmax)
			xmax = x2[i];
		if (y1[i] < ymin)
			ymin = y1[i];
		if (y2[i] > ymax)
			ymax = y2[i];
	}
	for (i = 0; i < n; i++) {
		if (x1[i] == xmin && x2[i] == xmax && y1[i] == ymin && y2[i] == ymax) {
			printf("TAK\n");
			return;
		}
	}
	printf("NIE\n");
}

int main() {
	int i, t;
	scanf("%d", &t);
	for(i = 0; i < t; i++)
		run();
	return 0;
}