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
#include <stdio.h>
using namespace std;

int t, n;
int w1[100000];
int w2[100000];
int h1[100000];
int h2[100000];
int w_min, w_max, h_min, h_max;
bool dominuje = false;

int main()
{
	scanf("%d", &t);
	
	for(int i = 0; i < t; i++)
	{
		scanf("%d", &n);
		
		w_min = 2000000000;
		w_max = 0;
		h_min = 2000000000;
		h_max = 0;
		
		dominuje = false;
		
		for(int j = 0; j < n; j++)
		{
			scanf("%d", &w1[j]);
			scanf("%d", &w2[j]);
			scanf("%d", &h1[j]);
			scanf("%d", &h2[j]);
			
			if(w_min > w1[j]) w_min = w1[j];
			if(w2[j] > w_max) w_max = w2[j];
			if(h_min > h1[j]) h_min = h1[j];
			if(h2[j] > h_max) h_max = h2[j];
		}
		
		for(int j = 0; j < n; j++)
		{
			if(w1[j] == w_min && w2[j] == w_max && h1[j] == h_min && h2[j] == h_max) { dominuje = true; break; }
		}
		
		if(dominuje) printf("TAK\n");
		else printf("NIE\n");
	}
	
	return 0;
}