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

#define INF 2000000000
#define MAXN 100001
int w1[MAXN],w2[MAXN];
int h1[MAXN],h2[MAXN];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int minw = INF,maxw = 1;
		int minh = INF,maxh = 1;
		int n;
		scanf("%d",&n);
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%d%d%d",w1+i,w2+i,h1+i,h2+i);
			minw = std::min(minw,w1[i]);
			maxw = std::max(maxw,w2[i]);
			minh = std::min(minh,h1[i]);
			maxh = std::max(maxh,h2[i]);
		}
		while(n--)
		{
			if(minw == w1[n] && maxw == w2[n] && minh == h1[n] && maxh == h2[n])
				break;
		}
		if(n == -1)
			puts("NIE");
		else
			puts("TAK");
	}
	return 0;
}