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
42
43
44
45
46
47
48
49
/*
 * lus.c
 *
 */
#include <stdio.h>
#include <stdlib.h>
int main() {
	int n, k, i, j, w1, w2, h1, h2, majoryzuje = 1;
	scanf("%i", &n);
	for (i = 0; i < n; i++) {
		scanf("%i", &k);
		int w1min = 1000000001;
		int w2max = -1;
		int h1min = 1000000001;
		int h2max = -1;
		for (j = 0; j < k; j++) {
			scanf("%i %i %i %i", &w1, &w2, &h1, &h2);
			if (w1 <= w1min && w2 >= w2max && h1 <= h1min && h2 >= h2max) {
				w1min = w1;
				w2max = w2;
				h1min = h1;
				h2max = h2;
				majoryzuje = 1;
			} else {
				if (w1 < w1min) {
					w1min = w1;
					majoryzuje = 0;
				}
				if (w2 > w2max) {
					w2max = w2;
					majoryzuje = 0;
				}
				if (h1 < h1min) {
					h1min = h1;
					majoryzuje = 0;
				}
				if (h2 > h2max) {
					h2max = h2;
					majoryzuje = 0;
				}
			}
		}
		if (majoryzuje)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
	return 0;
}