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
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<cstdio>

using namespace std;

int t, wp[100001], wk[100001], hp[100001], hk[100001], n;
int wpn = 1000000010, wkn, hpn = 1000000010, hkn;
int wyn;

int main()
{
	scanf("%d", &t);
	for( int a = 1; a <= t; a++ )
	{
		wpn = 1000000010;
		wkn = 0;
		hpn = 1000000010;
		hkn = 0;
		wyn = 0;
		scanf("%d", &n);
		for( int b = 1; b <= n; b++ )
		{
			scanf("%d", &wp[b]);
			scanf("%d", &wk[b]);
			scanf("%d", &hp[b]);
			scanf("%d", &hk[b]);
			wpn = min(wp[b], wpn);
			hpn = min(hp[b], hpn);
			wkn = max(wk[b], wkn);
			hkn = max(hk[b], hkn);		
		}
		for( int b = 1; b <= n; b++ )
		{
			if( wp[b] == wpn && wk[b] == wkn && hp[b] == hpn && hk[b] == hkn )
			{
				wyn = 1;
				break;
			}
		}
		if( wyn )printf("TAK\n");
		else printf("NIE\n");
	}	
	return 0;
}