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

using namespace std;

int t, n, a, b, c, d;
bool result;

int A[100005];
int B[100005];
int C[100005];
int D[100005];

int main ()
{
	scanf("%d",&t);
	while (t--)
	{
		result = false;
		a = c = 1000000001;
		b = d = 0;
		scanf("%d",&n);
		for (int i = 0; i < n; ++i)
		{
		    scanf("%d%d%d%d",&A[i],&B[i],&C[i],&D[i]);
			if (A[i] < a) a = A[i];
			if (B[i] > b) b = B[i];
			if (C[i] < c) c = C[i];
			if (D[i] > d) d = D[i];
		}
		for (int i = 0; i < n; ++i)
		{
			if ((A[i] == a) && (B[i] == b) && (C[i] == c) && (D[i] == d))
			{
				result = true;
				break;
			}
		}
		if (result == true) printf("TAK\n");
		else printf("NIE\n");
	}
	return 0;
}