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
#include <iostream>
using namespace std;
int main()
{
	int t,n;
	cin>>t;
	
	int w1[100000], h1[100000], w2[100000], h2[100000];
	for(int i=0;i<t;i++)
{
	cin>>n;
	   for(int i=0;i<n;i++)	cin>>w1[i]>>w2[i]>>h1[i]>>h2[i];
		
		 int min1=100000, maks1=0, min2=1000, maks2=0,k=0;
		for(int i=0;i<n;i++)
		{
			if(w1[i]<min1) min1=w1[i];
			if(w2[i]>maks1) maks1=w2[i];
			if(h1[i]<min2) min2=h1[i];
			if(h2[i]>maks2) maks2=h2[i];
			
			
		}
			for(int i=0;i<n;i++)
		{
			if(min1==w1[i] && min2==h1[i] && maks1==w2[i] && maks2==h2[i])
			{
				k=1;
				cout<<"TAK"<<endl;
				break;
			}
			
			
		}
		if(k==0) cout<<"NIE"<<endl;
	}
	
	
return 0;	
}