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
50
51
52
53
54
55
56
57
58
#include <cstdio>
#include <cstdlib>
#include <set>

using namespace std;

int main()
{
int N,n,t,T,*x1,*x2,*y1,*y2,x1m,x2m,y1m,y2m;
set<int> D,Dt;
	
	scanf("%d",&T);
	for (t = 0; t < T; t++)
	{
		scanf("%d",&N);
		
		x1 = (int*) malloc(N*sizeof(int));
		x2 = (int*) malloc(N*sizeof(int));
		y1 = (int*) malloc(N*sizeof(int));
		y2 = (int*) malloc(N*sizeof(int));
		x1m = y1m = 2000000000;
		x2m = y2m = 0;

		for (n = 0; n < N; n++)
		{
			scanf("%d %d %d %d",x1+n,x2+n,y1+n,y2+n);
			if (x1[n] < x1m) x1m = x1[n];
			if (x2[n] > x2m) x2m = x2[n];
			if (y1[n] < y1m) y1m = y1[n];
			if (y2[n] > y2m) y2m = y2[n];
		}
		
		D.clear();
		for (n = 0; n < N; n++)
			if (x1[n] == x1m) D.insert(n);			
		Dt.clear();
		for (n = 0; n < N; n++)
			if (x2[n] == x2m && D.find(n) != D.end()) Dt.insert(n);			
		D = Dt;
		Dt.clear();
		for (n = 0; n < N; n++)
			if (y1[n] == y1m && D.find(n) != D.end()) Dt.insert(n);			
		D = Dt;
		Dt.clear();
				for (n = 0; n < N; n++)
			if (y2[n] == y2m && D.find(n) != D.end()) Dt.insert(n);			
		D = Dt;
		Dt.clear();
		
		if (D.size() > 0) printf("TAK\n"); else printf("NIE\n");		
		free(x1);
		free(x2);
		free(y1);
		free(y2);
	}

	return 0;
}