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

int maxh, maxw, minh, minw, n, t, w, W1[100000], W2[100000], H1[100000], H2[100000];

int main() {
	scanf("%d", &t);
	while (t--) {
		minw = minh = 1000000001;
		maxw = maxh = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; ++i) {
			scanf("%d %d %d %d", &W1[i], &W2[i], &H1[i], &H2[i]);
			if (W1[i] < minw) minw = W1[i];
			if (W2[i] > maxw) maxw = W2[i];
			if (H1[i] < minh) minh = H1[i];
			if (H2[i] > maxh) maxh = H2[i];
		}
		w = 0;
		for (int i = 0; i < n; ++i) {
			if (minw == W1[i] && maxw == W2[i] && minh == H1[i] && maxh == H2[i]) {
				w = 1;
				break;
			}
		}
		puts(w ? "TAK" : "NIE");
	}
	return 0;
}