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
46
47
48
49
50
#include<iostream>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t,a=0;
	cin>>t;
	int x=0;
	for (int i=0; i<t; i++)
	{
		cin>>a;
		int wmi=1000000000, wma=0;
		int hmi=1000000000, hma=0;
		int w1[a];
		int w2[a];
		int h1[a];
		int h2[a];
		for (int j=0; j<a; j++)
		{
			cin>>w1[j];
			cin>>w2[j];
			cin>>h1[j];
			cin>>h2[j];
			if(w1[j]<wmi)
			wmi=w1[j];
			if(w2[j]>wma)
			wma=w2[j];
			if(h1[j]<hmi)
			hmi=h1[j];
			if(h2[j]>hma)
			hma=h2[j];
		}
		for (int j=0; j<a; j++)
		{
			if(w1[j]==wmi&&w2[j]==wma&&h1[j]==hmi&&h2[j]==hma)
			x=1;
		}
		if(x==1)
		cout<<"TAK\n";
		else
		cout<<"NIE\n";
		a=0;
		x=0;
	}
	return 0;
}