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
typedef struct {
	unsigned long w1;
	unsigned long w2;
	unsigned long h1;
	unsigned long h2;
} dimension_t;

int main(int argc, char *argv[]){
	unsigned int t;
	int i,j;
	
	scanf("%u\n", &t);

	for(i = 0; i < t; i++){
		unsigned int n;
		dimension_t * dim;
		dimension_t extremum = {0xffffffff, 1, 0xffffffff, 1};
		int f = 0;
		
		scanf("%u\n", &n);
		
		dim = (dimension_t *)malloc(sizeof(dimension_t) * n);
		
		for(j = 0; j < n; j++){
			scanf("%lu %lu %lu %lu", &dim[j].w1, &dim[j].w2, &dim[j].h1, &dim[j].h2);
			
			if(dim[j].w1 < extremum.w1)
				extremum.w1 = dim[j].w1;
			if(dim[j].w2 > extremum.w2)
				extremum.w2 = dim[j].w2;
			if(dim[j].h1 < extremum.h1)
				extremum.h1 = dim[j].h1;
			if(dim[j].h2 > extremum.h2)
				extremum.h2 = dim[j].h2;
		}
		for(j = 0; j < n; j++){
			if(	dim[j].w1 == extremum.w1)
				if(	dim[j].w2 == extremum.w2)
					if(	dim[j].h1 == extremum.h1)
						if(	dim[j].h2 == extremum.h2){
							printf("TAK\n");
							f = 1;
							break;
						}
		}
		if(!f)
			printf("NIE\n");
		
		free(dim);
	}
}