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

using namespace std;


int main()
{
	int t, n, w1, h1, w2, h2, wMax, hMax, wMin, hMin;
	bool major;
	
	scanf("%d\n", &t);
	while (t--)
	{
		major = false;
		wMax = 0;
		hMax = 0;
		wMin = 999999999;
		hMin = 999999999;
		scanf("%d\n", &n);
		for (int i = 0; i < n; i++)
		{
			scanf("%d %d %d %d\n", &w1, &w2, &h1, &h2);
		
			if (w2 >= wMax && h2 >= hMax && w1 <= wMin && h1 <= hMin)
			{
				wMax = w2;
				hMax = h2;
				wMin = w1;
				hMin = h1;
				major = true;
			}
			else if (w2 > wMax )
			{
				wMax = w2;
				major = false;
			}
			else if (h2 > hMax )
			{
				hMax = h2;
				major = false;
			}
			else if (w1 < wMin )
			{
				wMin = w1;
				major = false;
			}
			else if (h1 < hMin )
			{
				hMin = h1;
				major = false;
			}
			
				}	
			if (major)
				printf("TAK\n");
			else
				printf("NIE\n");
	}
	
	
	return 0;
}