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
# include <cstdio>
# define MN 100000
int x1[MN], x2[MN], y1[MN], y2[MN];
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		int n;
		scanf("%d", &n);
		for (int i=0; i<n; ++i)
			scanf("%d%d%d%d", x1+i, x2+i, y1+i, y2+i);
		int minx=x1[0], maxx=x2[0], miny=y1[0], maxy=y2[0];
		for (int i=1; i<n; ++i)
		{
			if (minx>x1[i])
				minx=x1[i];
			if (miny>y1[i])
				miny=y1[i];
			if (maxx<x2[i])
				maxx=x2[i];
			if (maxy<y2[i])
				maxy=y2[i];
		}
		bool any=false;
		for (int i=0; i<n; ++i)
			if (minx==x1[i] && miny==y1[i] && maxx==x2[i] && maxy==y2[i])
			{
				any=true;
				break;
			}
		if (any)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
}