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
#include <cstdio>
#include <algorithm>
using namespace std;

const int INF = 1000000033;
const int MX = 100010;

int main ()
{
	int t, n, w_min, w_max, h_min, h_max;
	int w1[MX], w2[MX], h1[MX], h2[MX];
	
	scanf ("%d", &t);
	for (int j = 0; j < t; ++j)
	{
		w_min = INF; w_max = -INF; h_min = INF; h_max = -INF;
		scanf ("%d", &n);
		for (int i = 0; i < n; ++i)
		{
			scanf ("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
			w_min = min(w_min, w1[i]);
			w_max = max(w_max, w2[i]);
			h_min = min(h_min, h1[i]);
			h_max = max(h_max, h2[i]);
		}
		bool res = false;
		for (int i = 0; i < n; ++i)
			if (w1[i] <= w_min && w2[i] >= w_max && h1[i] <= h_min && h2[i] >= h_max)
				res = true;
				
		if (res)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
}