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
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) 
{
	long long w1min,w2maks,h1min,h2maks;
	int t,n;
	bool test=0;
	long long w1,w2,h1,h2;
	cin>>t;
	for(int j=0;j<t;j++){
	cin>>n;
	for(int i=0;i<n;i++)
	{
	if(i==0)
	{
	cin>>w1min;
	cin>>w2maks;
	cin>>h1min;
	cin>>h2maks;	
	}	
	else
	{
	cin>>w1;
	cin>>w2;
	cin>>h1;
	cin>>h2;
	if(w1<=w1min&&w2>=w2maks&&h1<=h1min&&h2>=h2maks)
	{
	w1min=w1;
	w2maks=w2;
	h1min=h1;
	h2maks=h2;
	test=1;	
	}
	//else if (w1>=w1min&&w2<=w2maks&&h1>=h1min&&h2<=h2maks)test=1;	
	}
	}
	if(test==0)cout<<"NIE"<<endl;
	else cout<<"TAK"<<endl;
	test=0;
}
	
	return 0;
}