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

int w1[101000];
int w2[101000];
int h1[101000];
int h2[101000];

int main() {
	int T;
	scanf("%d",&T);
	
	while (T--) {
		int n,minw=1100000000,minh=1100000000,maxw=0,maxh=0;
		bool ok = false;
		scanf("%d",&n);

		for (int i=0;i<n;++i) {
			scanf("%d %d %d %d",&w1[i],&w2[i],&h1[i],&h2[i]);
			minw = std::min(minw, w1[i]);
			minh = std::min(minh, h1[i]);
			maxw = std::max(maxw, w2[i]);
			maxh = std::max(maxh, h2[i]);
		}

		for (int i=0; i<n; ++i) {
			if (w1[i]==minw && w2[i]==maxw && h1[i]==minh && h2[i]==maxh) ok = true;
		}
		
		printf("%s\n",(ok?"TAK":"NIE"));
	}

	return 0;
}