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
59
60
61
62
63
64
65
66
67
68
69
70
// Piotr Golda
#define _CRT_SECURE_NO_WARNINGS  
#include <iostream>
#include <cstdio>
using namespace std;


#define MAX_NUM 100000

int T, N;

int RANGE[MAX_NUM][4];
int min_w, max_w, min_h, max_h;

void scan()
{
	min_w = 1000000001;
	max_w = 0;
	min_h = 1000000001;
	max_h = 0;
	scanf("%d", &N);

	for(int i = 0; i < N; ++i)
	{
		scanf("%d", &RANGE[i][0]);
		if(RANGE[i][0] < min_w)
			min_w = RANGE[i][0];
		scanf("%d", &RANGE[i][1]);
		if(RANGE[i][1] > max_w)
			max_w = RANGE[i][1];
		scanf("%d", &RANGE[i][2]);
		if(RANGE[i][2] < min_h)
			min_h = RANGE[i][2];
		scanf("%d", &RANGE[i][3]);
		if(RANGE[i][3] > max_h)
			max_h = RANGE[i][3];
	}
}

bool check()
{
	for(int i = 0; i < N; ++i)
	{
		if(
			(RANGE[i][0] == min_w) &&
			(RANGE[i][1] == max_w) &&
			(RANGE[i][2] == min_h) &&
			(RANGE[i][3] == max_h)
			)
			return true;
	}
	return false;
}


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

	for(int i = 0; i < T; i++)
	{
		scan();
		if( check() )
			printf("TAK\n");
		else
			printf("NIE\n");
	}

	return 0;
}