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
#include <stdio.h>
const int SIZE = 100000;
int main()
{
	int w1[SIZE];
	int w2[SIZE];
	int h1[SIZE];
	int h2[SIZE];
	int t, n, N, W1, W2, H1, H2;
	scanf("%d\n", &t);

	for (; t > 0; --t)
	{
		scanf("%d\n", &N);
		W1 = H1 = 1000000000;
		W2 = H2 = 1;
		for (n = 0; n < N; ++n)
		{
			scanf("%d %d %d %d\n", &w1[n], &w2[n], &h1[n], &h2[n]);
			if (w1[n] < W1) W1 = w1[n];
			if (w2[n] > W2)	W2 = w2[n];
			if (h1[n] < H1) H1 = h1[n];
			if (h2[n] > H2)	H2 = h2[n];
		}
		for (n = 0; n < N; ++n)
		{
			if (w1[n] == W1 && w2[n] == W2 && h1[n] == H1 && h2[n] == H2)
				break;				
		}
		if (n < N)
			printf("TAK\n");
		else
			printf("NIE\n");
	}
	return 0;
}