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

int main()
{
	int t;
	scanf("%d", &t);
	for(int ti = 0; ti < t; ti++)
	{
		int n;
		scanf("%d", &n);
		
		int A = 1000 * 1000 * 1000 + 7;
		int B = -1;
		int C  = 1000 * 1000 * 1000 + 7;
		int D = -1;
		
		bool x = false;
		
		for(int i = 0; i < n; i++)
		{
			int a, b, c, d;
			scanf("%d %d %d %d", &a, &b, &c, &d);
			
			if(a < A)
			{
				A = a;
				x = false;
			}
			if(b > B)
			{
				B = b;
				x = false;
			}
			if(c < C)
			{
				C = c;
				x = false;
			}
			if(d > D)
			{
				D = d;
				x = false;
			}	
			
			if(a == A && b == B && c == C && d == D)
				x = true;
		}
		
		if(x == true)
			printf("TAK\n");
		else
			printf("NIE\n");
	}	
	
	return 0;
}