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


int main(int argc, char** argv) {
	
	int testNumber;
    scanf ("%d\n",&testNumber);

	int firmNumber;
	int* w1;
	int* w2;
	int* h1;
	int* h2;
	
	w1 = new int[100001];
	w2 = new int[100001];
	h1 = new int[100001];
	h2 = new int[100001];
	for(int j = 0; j < testNumber; ++j){

		scanf("%d\n",&firmNumber);
		
		
		for(int i = 0; i< firmNumber; ++i){
			scanf("%d %d %d %d\n", &w1[i],&w2[i], &h1[i], &h2[i]);
		}
		//find min and max
		int minW = 2000000000, minH = 2000000000, maxW = 0, maxH = 0;
		for(int i = 0; i< firmNumber; ++i){
			if(w1[i] < minW) minW = w1[i];
			if(w2[i] > maxW) maxW = w2[i];
			if(h1[i] < minH) minH = h1[i];
			if(h2[i] > maxH) maxH = h2[i];
		}
		int counter = 0;
		for(int i = 0; i< firmNumber; ++i){
			if(w1[i] == minW){
				if(w2[i] == maxW){
					if(h1[i] == minH){
						if(h2[i] == maxH){
							counter++;
							break;
						}
					}
				}
			}
		}
		if(counter > 0){
			printf("TAK\n");
		}else{
			printf("NIE\n");
		}				
	}	
	
	delete [] w1;
	delete [] w2;
	delete [] h1;
	delete [] h2;
	
    return 0;
}