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
#include <cstdio>
#include <algorithm>

const int MAX = (const int)10e5;
const unsigned int INF = 0-1;

using namespace std;

unsigned int W1[MAX];
unsigned int W2[MAX];
unsigned int H1[MAX];
unsigned int H2[MAX];

int main()
{
	int cout;
	scanf("%d", &cout);

	while(--cout>=0)
	{
		int N;
		scanf("%d", &N);

		unsigned int w1_min = INF;
		unsigned int w2_max = 0;
		unsigned int h1_min = INF;
		unsigned int h2_max = 0;
		for(int i = 0; i<N; i++)
		{
			scanf("%d %d %d %d", &W1[i], &W2[i], &H1[i], &H2[i]);
			w1_min = min(w1_min, W1[i]);
			w2_max = max(w2_max, W2[i]);
			h1_min = min(h1_min, H1[i]);
			h2_max = max(h2_max, H2[i]);
		}

		int num = 0;

		for(int i = 0; i<N; i++)
		{
			if(w1_min == W1[i] && w2_max == W2[i] && h1_min == H1[i] && h2_max == H2[i])
			{
				num++;
			}
		}

		if(num > 0) printf("TAK\n");
		else printf("NIE\n");

	}

	return 0;
}