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
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		int w1[n], w2[n], h1[n], h2[n];
		int minW, maxW, minH, maxH;
		scanf("%d%d%d%d", &w1[0], &w2[0], &h1[0], &h2[0]);
		minW = w1[0];
		maxW = w2[0];
		minH = h1[0];
		maxH = h2[0];
		for (int i = 1; i < n; i++) {
			scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
			minW = min(minW, w1[i]);
			maxW = max(maxW, w2[i]);
			minH = min(minH, h1[i]);
			maxH = max(maxH, h2[i]);
		}
		bool tak = false;
		for (int i = 0; i < n; i++) {
			if (w1[i] == minW && w2[i] == maxW && h1[i] == minH && h2[i] == maxH) {
				tak = true;
				break;
			}
		}
		if (tak) puts("TAK");
		else puts("NIE");
	}
	return 0;
}