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
#include <bits/stdc++.h>

#define FWD(a,b,c) for(int a=(b); a<(c); ++a)

using namespace std;

const int INF = 1000000010;

int n;
bool maj;
int mw1, mw2, mh1, mh2, w1, w2, h1, h2;

int main(){
	int z; scanf("%d", &z); while(z--){
		scanf("%d", &n);
		mw1 = mh1 = INF;
		mw2 = mh2 = 0;
		FWD(i,0,n){
			scanf("%d %d %d %d", &w1, &w2, &h1, &h2);
			if(w1 < mw1) maj = 0, mw1 = w1;
			if(w2 > mw2) maj = 0, mw2 = w2;
			if(h1 < mh1) maj = 0, mh1 = h1;
			if(h2 > mh2) maj = 0, mh2 = h2;
			if(w1 == mw1 && w2 == mw2 && h1 == mh1 && h2 == mh2)
				maj = 1;
		}
		printf(maj?"TAK\n":"NIE\n");
	}
	return 0;
}