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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
	int T;
	cin >> T;
	for( int t = 0; t < T; ++t )
	{
		int N;
		cin >> N;
		int* tab = new int[4*N];
		int minx;
		int maxx;
		int miny;
		int maxy;
		cin >> minx >> maxx >> miny >> maxy;
		tab[0] = minx;
		tab[1] = maxx;
		tab[2] = miny;
		tab[3] = maxy;
		for( int n = 1; n < N; ++n )
		{
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			tab[n*4] = a;
			tab[n*4+1] = b;
			tab[n*4+2] = c;
			tab[n*4+3] = d;
			if( a < minx )
				minx = a;
			if( b > maxx )
				maxx = b;
			if( c < miny )
				miny = c;
			if( d > maxy )
				maxy = d;
		}
		bool can = false;
		for( int n = 0; n < N; ++n )
		{
			if( tab[n*4] == minx && tab[n*4+1] == maxx && tab[n*4+2] == miny && tab[n*4+3] == maxy )
			{
				can = true;
				break;
			}
		}
		if( can )
			printf("TAK\n");
		else
			printf("NIE\n");
	}
	return 0;
}