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
59
60
61
62
63
64
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int t,n,w1[100001],w2[100001],h1[100001],h2[100001];
int x1,x2,y1,y2;
int main()
{

scanf("%d",&t);

for(int i=0;i<t;i++)
{
	x1=1000000009;
	x2=0;
	y1=1000000009;
	y2=0;
	
	scanf("%d",&n);
	
	for(int j=0;j<n;j++)
	{
		scanf("%d %d %d %d",&w1[j],&w2[j],&h1[j],&h2[j]);
		
		if(w1[j]<=x1&&w2[j]>=x2&&h1[j]<=y1&&h2[j]>=y2)
		{
			x1=w1[j];
			x2=w2[j];
			y1=h1[j];
			y2=h2[j];
		}
	}
	
	int z=0,zz=0;
	
	for(int j=0;j<n;j++)
	{
		if(w1[j]>=x1&&w2[j]<=x2&&h1[j]>=y1&&h2[j]<=y2)
		{
			z++;
		}
	}
	z--;
	
	if(z==n-1)
	{
		printf("TAK\n");
	}
	else
	{
		printf("NIE\n");
	}
	
}






cin.ignore();
getchar();
return 0;
}