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>
#define MAX 100001

int t,n,w1[MAX],w2[MAX],h1[MAX],h2[MAX],best;
bool w;

int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		best=0;
		w=true;
		for(int i=0; i<n; ++i){
			scanf("%d%d%d%d",&w1[i],&w2[i],&h1[i],&h2[i]);
			if(w1[i]<w1[best] || w2[i]>w2[best] || h1[i]<h1[best] || h2[i]>h2[best]) w=false;
			if(w1[i]<=w1[best])
				if(w2[i]>=w2[best])
					if(h1[i]<=h1[best])
						if(h2[i]>=h2[best]){
							best=i;
							w=true;
						}

		}
		if(w) printf("TAK\n");
		else printf("NIE\n");
	}
	return 0;
}