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
43
44
45
#include <iostream>
#include <cstdio>
using namespace std;
const int DUZA = 1000000004;
int main()
{
	int t, n, zap;
	int a1, a2, b1, b2;
	int w1,w2,h1,h2;
	int mi1,ma1,mi2,ma2;
	bool tak = 0;
	scanf("%d", &t);
	for(int g = 0 ; g < t ; g++)
	{
		scanf("%d", &n);
		tak=0;
		mi1=DUZA;
		ma1=0;
		mi2=DUZA;
		ma2=0;
		for(int i = 0 ; i < n ; i++)
		{
			scanf("%d%d%d%d", &w1,&w2,&h1,&h2);
			if(w1 <= mi1 && w2 >= ma1 && h1 <= mi2 && h2 >= ma2)
			{
				mi1=w1;
				ma1=w2;
				mi2=h1;
				ma2=h2;
				zap=i;
			}
			if(w1 < mi1 || w2 > ma1 || h1 < mi2 || h2 > ma2)
				tak=1;
		}
		//cout<<mi1<<" "<<ma1<<" "<<mi2<<" "<<ma2<<endl;
		if(zap != 0)
			printf("TAK\n");
		else if(zap == 0 && tak ==0)
			printf("TAK\n");
		else
			printf("NIE\n");
		
	}
	return 0;
}