1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
int t, n, w1 [100000], w2 [100000], h1 [100000], h2 [100000], w_max, w_min, h_max, h_min, ret;
int main () {
	scanf ("%d", &t);
	while (t--) {
		scanf ("%d", &n);
		ret = w_max = h_max = 0;
		w_min = h_min = 2000000000;
		for (int i = 0; i < n; i ++) {
			scanf ("%d %d %d %d", &w1 [i], &w2 [i], &h1 [i], &h2 [i]);
			if (w1 [i] < w_min) w_min = w1 [i];
			if (w2 [i] > w_max) w_max = w2 [i];
			if (h1 [i] < h_min) h_min = h1 [i];
			if (h2 [i] > h_max) h_max = h2 [i];
		}
		for (int i = 0; i < n && !ret; i ++) if (w1 [i] == w_min && w2 [i] == w_max && h1 [i] == h_min && h2 [i] == h_max) ret ++;
		if (ret) printf ("TAK\n");
		else printf ("NIE\n");
	}
}