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
74
75
76
#include <iostream>
using namespace std;

struct firm
{
	int w1;
	int w2;
	int h1;
	int h2;
};

int main() {
	int n;
	cin>>n;
	for(int i =0; i<n;i++)
	{
		int k;
		cin>>k;
		firm* tab = new firm[k];
		
		
		
		firm fk;
		cin>>fk.w1;
		cin>>fk.w2;
		cin>>fk.h1;
		cin>>fk.h2;
		tab[0] = fk;
		
		int min_w1 = fk.w1;
		int max_w2 = fk.w2;
		int min_h1 = fk.h1;
		int max_h2 = fk.h2;
		
		for(int j = 1; j<k;j++)
		{
			firm f;
			cin>>f.w1;
			cin>>f.w2;
			cin>>f.h1;
			cin>>f.h2;
			tab[j] = f;
			
			if(min_w1 > f.w1)
				min_w1 = f.w1;
			if(max_w2 < f.w2)
				max_w2 = f.w2;
			if(min_h1 > f.h1)
				min_h1 = f.h1;
			if(max_h2 < f.h2)
				max_h2 = f.h2;
		}
		
		bool res = false;
		
		for(int j = 0; j<k;j++)
		{
			if( tab[j].w1 == min_w1
			&& tab[j].w2 == max_w2
			&& tab[j].h1 == min_h1
			&& tab[j].h2 == max_h2)
			{
				cout<<"TAK\n";
				res = true;
				break;
			}
			
		}
		
		if(!res)
			cout<<"NIE\n";
	}
	
	
	return 0;
}