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
65
66
#include <iostream>
#include <cstdio>



int main(int argc, char** argv) {
	
	int t;
	scanf("%d",&t);
	while(t--) {
		int minw1=1000000009;
		int maxw2=-9;
		int minh1=1000000009;
		int maxh2=-9;
		
		int rememberW1;
		int rememberW2;
		int rememberH1;
		int rememberH2;
		
		int n;
		scanf("%d",&n);
		
		int w1,w2,h1,h2;
		for (int i = 0; i < n; ++i) {
			scanf("%d%d%d%d",&w1,&w2,&h1,&h2);
			int counter = 0;
			
			if (w1 <= minw1) {
 				minw1 = w1;
 				counter++;
			}
			if (w2 >= maxw2) {
 				maxw2 = w2;
 				counter++;
			}
			if (h1 <= minh1) {
 				minh1 = h1;
 				counter++;
			}
			if (h2 >= maxh2) {
 				maxh2 = h2;
 				counter++;
			}
			
			if(counter == 4) {
				rememberW1 = w1;
				rememberW2 = w2;
				rememberH1 = h1;
				rememberH2 = h2;
			}
		}
		
		if (minw1 == rememberW1 && maxw2 == rememberW2 && minh1 == rememberH1 && maxh2 == rememberH2) {
			printf("TAK\n");
		} else {
			printf("NIE\n");
		}
		
	}
	
	
	
	
	return 0;
}