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

#define INF 1000000009
#define MAXN 100003

int t,n;

int w1[MAXN];
int w2[MAXN];
int h1[MAXN];
int h2[MAXN];

bool odp;

int min_w,max_w,min_h,max_h;

int main(){
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		min_w = INF;
		max_w = 0;
		min_h = INF;
		max_h = 0;
		
		odp = false;
		
		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] < min_w)min_w = w1[j];
			if(w2[j] > max_w)max_w = w2[j];
			if(h1[j] < min_h)min_h = h1[j];
			if(h2[j] > max_h)max_h = h2[j];
		}
		for(int j=0;j<n;j++){
			if((w1[j] == min_w) && (w2[j] == max_w) && (h1[j] == min_h) && (h2[j] == max_h)){
				odp = true;
				break;	
			}
		}
		if(odp == true)printf("TAK\n");
		else printf("NIE\n");
	}


return 0;
}