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

#define M 100000
#define IM 1000000001

using namespace std;

int w1[M],w2[M],h1[M],h2[M];

int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }

int main() {
	int a,b,c,d,W1,W2,H1,H2,n,t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		W1 = IM;
		W2 = 0;
		H1 = IM;
		H2 = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
			W1 = min(W1, w1[i]);
			W2 = max(W2, w2[i]);
			H1 = min(H1, h1[i]);
			H2 = max(H2, h2[i]);
		}

		bool occur = false;
		for (int i = 0; i < n; i++) {
			if (W1 == w1[i] && W2 == w2[i] && H1 == h1[i] && H2 == h2[i]) {
				occur = true;
				break;
			}
		}
		printf("%s\n", occur ? "TAK" : "NIE");
	}
	return 0;
}