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
#include<iostream>

const unsigned int INF=1000000009;

int main(){
	std::ios_base::sync_with_stdio(false);
	
	unsigned int t,n;
	std::cin>>t;
	
	while(t--){
		std::cin>>n;
		bool sol=false;
		unsigned int min_w=INF,max_w=0,min_h=INF,max_h=0;
		unsigned int A[4];
		while(n--){
			std::cin>>A[0]>>A[1]>>A[2]>>A[3];
			if(A[0]<min_w) min_w=A[0],sol=false;
			if(A[1]>max_w) max_w=A[1],sol=false;
			if(A[2]<min_h) min_h=A[2],sol=false;
			if(A[3]>max_h) max_h=A[3],sol=false;
			
			if(A[0]==min_w&&A[1]==max_w&&A[2]==min_h&&A[3]==max_h)
				sol=true;
		}
		
		std::cout<<(sol?"TAK":"NIE")<<"\n";
	}
	
	return 0;
}