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

int main(){
	int z;
	scanf("%d",&z);
	while(z--){
		int n; 
		scanf("%d",&n);
		int minw,minh,maxw,maxh;
		minw = minh = 1000000005;
		maxw = maxh = 0;
		bool majozer = false;

		for(int i=0;i<n;i++){
			int w1,w2,h1,h2;
			scanf("%d%d%d%d",&w1,&w2, &h1, &h2);
			if(w1<minw){minw = w1;majozer=false;}
			if(w2>maxw){maxw = w2;majozer=false;}
			if(h1<minh){minh = h1;majozer=false;}
			if(h2>maxh){maxh = h2;majozer=false;}

			if(w1 == minw && w2 == maxw && h1 == minh && h2 == maxh)
				majozer = true;
		}

		printf("%s\n",majozer?"TAK":"NIE");
	}
	return 0;
}