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
51
52
53
54
55
56
57
58
59
#include <iostream>

using namespace std;

struct ofe{
	int w1,w2;
	int h1,h2;
};


int gw1,gw2;
int gh1,gh2;

int n;
int t;

bool check;

int main(){
	ios_base::sync_with_stdio(0);

	cin >> t;

	for (int k = 0; k < t; ++k)
	{	
		check = false;

		cin >> n;

		ofe tab[n];

		for (int i = 0; i < n; ++i)
		{
			cin >> tab[i].w1 >> tab[i].w2 >> tab[i].h1 >> tab[i].h2;
		}
			gw1 = tab[0].w1;
			gw2 = tab[0].w2;
			gh1 = tab[0].h1;
			gh2 = tab[0].h2;

		for (int i = 1; i < n; ++i)
		{
			if(gw1 > tab[i].w1)gw1 = tab[i].w1;
			if(gh1 > tab[i].h1)gh1 = tab[i].h1;
			if(gw2 < tab[i].w2)gw2 = tab[i].w2;
			if(gh2 < tab[i].h2)gh2 = tab[i].h2;
		}

		for (int i = 1; i < n; ++i)
		{
			if(gw1 == tab[i].w1 && gh1 == tab[i].h1 && gw2 == tab[i].w2 && gh2 == tab[i].h2)check = true;
		}

		if(check)cout << "TAK";
		else cout << "NIE";
		cout << "\n";
	}
		return 0;
}