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 minW[100000];
int maxW[100000];

int minH[100000];
int maxH[100000];

int main(){
	int t,n;
	cin>>t;
	while(t--){
		cin>>n;
		for(int i = 0; i < n; i++)
			cin>>minW[i]>>maxW[i]>>minH[i]>>maxH[i];
		int MINW = minW[0];
		int MAXW = maxW[0];
		int MINH = minH[0];
		int MAXH = maxH[0];
		for(int i = 1; i < n; i++){
			if(MINW > minW[i])MINW  = minW[i];
			if(MINH > minH[i])MINH  = minH[i];
			if(MAXW < maxW[i])MAXW  = maxW[i];
			if(MAXH < maxH[i])MAXH  = maxH[i];
		}
		int ok = 0;
		for(int i=0;i<n;i++)
			if(minW[i] == MINW && minH[i] ==MINH && maxW[i] == MAXW && maxH[i] == MAXH){
				ok = 1;break;
			}
		if(ok)
			cout<<"TAK\n";
		else
			cout<<"NIE\n";
	}
	return 0;
}