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
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int t,n,w1,w2,h1,h2,maxw=0,maxh=0,miw=1000000001,mih=1000000001,k;
	int maksw[100001],maksh[100001],minw[100001],minh[100001];
	cin>>t;
	for(int i=0;i<t;i++)
	{
		k=0;
		maxw=0;
		maxh=0;
		miw=1000000001;
		mih=1000000001;
		cin>>n;
		for(int i=0;i<n;i++)
		{
			cin>>minw[i]>>maksw[i]>>minh[i]>>maksh[i];
		if(maksh[i]>=maxh )maxh=maksh[i];
		if (minh[i]<=mih)mih=minh[i];  
		if( maksw[i]>=maxw)  maxw=maksw[i];
		if( minw[i]<=miw) miw=minw[i];
			
		}
		for(int i=0;i<n;i++)
		{
		if(maxh==maksh[i] && mih==minh[i] && maxw==maksw[i] && miw==minw[i] )  k=1; 
		}
		if(k==1) cout<<"TAK"<<endl;
		else cout<<"NIE"<<endl;
		
}
	

	return 0;
}