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
#include <cstdio>
#include <algorithm>
using namespace std;

const int N=100007;

int t,n,w1[N],w2[N],s1[N],s2[N],mw1,mw2,ms1,ms2;

int main(){
	scanf("%d", &t);
	for(int k=0;k<t;k++){
		scanf("%d", &n);
		mw1=2000000000; ms1=2000000000; mw2=0; ms2=0; 
		for(int i=0;i<n;i++){
			scanf("%d%d%d%d", &w1[i], &w2[i], &s1[i], &s2[i]);
			mw1=min(mw1, w1[i]);
			ms1=min(ms1, s1[i]);
			mw2=max(mw2, w2[i]);
			ms2=max(ms2, s2[i]);
		}
		bool tak=false;
		for(int i=0;i<n;i++){
			if(w1[i]==mw1 && s1[i]==ms1 && w2[i]==mw2 && s2[i]==ms2){
				puts("TAK");
				tak=true;
				break;
			}
		}
		if(!tak) puts("NIE");
	}
	return 0;
}