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

#define REP(i,n) for(int i=0;i<(n);++i)

const int INF = 1000000001;
const int MAX = 100010;

int w1[MAX], w2[MAX], h1[MAX], h2[MAX];
int n;

int main(int argc, char *argv[]) {
	int z;
	scanf("%d", &z);
	while(z--)
	{
		scanf("%d", &n);
		int minw = INF, maxw = 0, minh = INF, maxh = 0;
		REP(i,n)
		{
			scanf("%d %d %d %d", w1+i, w2+i, h1+i, h2+i);
			if(w1[i] < minw) minw = w1[i];
			if(w2[i] > maxw) maxw = w2[i];
			if(h1[i] < minh) minh = h1[i];
			if(h2[i] > maxh) maxh = h2[i];
		}
		bool res = false;
		REP(i,n)
			res |= (w1[i] == minw && w2[i] == maxw && h1[i] == minh && h2[i] == maxh);
		printf("%s\n", res ? "TAK" : "NIE");
	}
	return 0;
}