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
#include<cstdio>
#include<algorithm>
using namespace std;
int tab[100005][5], maxw, maxh, minw, minh;
int main ()
{
	int t;
	scanf ( "%d", &t );
	while ( t -- )
	{
		int n;
		scanf ( "%d", &n );
		for ( int j = 1; j <= n; j ++ )
		{
			for ( int i = 0; i < 4; i ++ ) scanf ( "%d", &tab[j][i] );
			if ( j == 1 ) 
			{
				maxw = tab[1][1];
				minw = tab[1][0];
				maxh = tab[1][3];
				minh = tab[1][2];
			}
			else
			{
				maxw = max(tab[j][1], maxw);
				minw = min(tab[j][0], minw);
				maxh = max(tab[j][3], maxh);
				minh = min(tab[j][2], minh);
			}
		}
		bool c = 0;
		for ( int j = 1; !c and j <= n; j ++ )
			if ( maxw == tab[j][1] and minw == tab[j][0] and maxh == tab[j][3] and minh == tab[j][2] ) c = 1;
		if ( c ) puts ( "TAK" );
		else puts ( "NIE" );
	}
	return 0;
}