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
#include <cstdio>
#include <algorithm>
using namespace std;

const int INF = 1e9 + 5, MX = 1e6 + 20;
int min_h[MX], max_h[MX], min_w[MX], max_w[MX], a, b, c, d, n, q;
bool czy = false;

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

	while(q--)
	{
		scanf("%d", &n);
	
		a = INF; b = 0; c = INF; d = 0;

		for(int i = 0; i < n; ++ i)
		{
			scanf("%d%d%d%d", &min_h[i], &max_h[i], &min_w[i], &max_w[i]);

			a = min(a,min_h[i]);
			b = max(b,max_h[i]);
			c = min(c,min_w[i]);
			d = max(d,max_w[i]);
		}
		
		czy = false;

		for(int i = 0; i < n; ++ i)
			if(a == min_h[i] && b == max_h[i] && c == min_w[i] && d == max_w[i])
			{
				czy = true;
				break;
			}
	
		puts(czy ? "TAK" : "NIE");
	}

	return 0;
}