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

typedef struct {
	int wmin;
	int wmax;
	int hmin;
	int hmax;
} dim;

dim t[100000];

int main()
{
	int z;

	scanf("%d", &z);
	while (z--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < n; i++) {
			scanf("%d %d %d %d", &t[i].wmin, &t[i].wmax, &t[i].hmin, &t[i].hmax);
		}
		int wmin = t[0].wmin;
		int wmax = t[0].wmax;
		int hmin = t[0].hmin;
		int hmax = t[0].hmax;
		for (int i = 1; i < n; i++) {
			if (t[i].wmin < wmin) wmin = t[i].wmin;
			if (t[i].wmax > wmax) wmax = t[i].wmax;
			if (t[i].hmin < hmin) hmin = t[i].hmin;
			if (t[i].hmax > hmax) hmax = t[i].hmax;
		}
		bool b = false;
		for (int i = 0; i < n && !b; i++) {
			if (t[i].wmin <= wmin && t[i].wmax >= wmax && t[i].hmin <= hmin && t[i].hmax >= hmax) {
				b = true;
			}
		}
		b ? printf("TAK\n") : printf("NIE\n");
	}
}