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

using namespace std;
const int ROZM = 100009;

int t,n, minsz[ROZM], maxsz[ROZM], minw[ROZM], maxw[ROZM];

int main()
{
	scanf("%d", &t);
	for (int j = 0; j < t; j++)
	{
		int minimw = 1000000009;
		int maximw = 0;
		int maximsz = 0;
		int minimsz = 1000000009;
		int pom = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
		{
			scanf("%d%d%d%d", &minsz[i], &maxsz[i], &minw[i], &maxw[i]);
			if (minsz[i] < minimsz)
				minimsz = minsz[i];
			if (minw[i] < minimw)
				minimw = minw[i];
			if (maxsz[i] > maximsz)
				maximsz = maxsz[i];
			if (maxw[i] > maximw)
				maximw = maxw[i];
		}
		for (int i = 0; i < n; i++)
		{
			if (minsz[i] == minimsz && minw[i] == minimw && maxsz[i] == maximsz && maxw[i] == maximw)
				{printf("TAK\n"); pom = 1; break;}
		}
		if (pom == 0) printf("NIE\n");
	}
	return 0;
}