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
67
68
69
70
71
72
73
#include <iostream>
#include <stdio.h>

using namespace std;

int s[100100][4];

int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(0);
	
	int t;
	int n;
	int w1, w2, h1, h2;
	
	int wMin;
	int wMax;
	int hMin;
	int hMax;
	
	int found;
	
	
	cin>>t;
	while(t--){
		
		wMin = 2000000000;
		wMax = -1;
		
		hMin = 2000000000;
		hMax = -1;

		cin>>n;
		for(int i = 0; i < n; i++){
			
			cin>>w1>>w2>>h1>>h2;
			
			s[i][0] = w1;
			s[i][1] = w2;
			s[i][2] = h1;
			s[i][3] = h2;
						
			if(w1 < wMin)
				wMin = w1;
			
			if(w2 > wMax)
				wMax = w2;
		
			if(h1 < hMin)
				hMin = h1;
			
			if(h2 > hMax)
				hMax = h2;
		}

		found = 0;
		
		for(int i = 0; i < n; i++){
			
			if(s[i][0] == wMin && s[i][1] == wMax && s[i][2] == hMin && s[i][3] == hMax)
			{
				found = 1;
			}
		}
		
		if(found == 1)
			puts("TAK");
		else
			puts("NIE");
				
	}
		
	return 0;
}