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

using namespace std;

#define MIN_W	0
#define MAX_W	1000000010
#define MIN_H	0
#define MAX_H	1000000010

int t, n, w1, w2, h1, h2;
int mw1, mw2, mh1, mh2, f;

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		mw1 = MAX_W; mw2 = MIN_W; mh1 = MAX_H; mh2 = MIN_H;
		f = 0;
		while (n--) {
			scanf("%d %d %d %d", &w1, &w2, &h1, &h2);

			if (w1 < mw1) { mw1 = w1; f = 0; }
			if (w2 > mw2) { mw2 = w2; f = 0; }
			if (h1 < mh1) { mh1 = h1; f = 0; }
			if (h2 > mh2) { mh2 = h2; f = 0; }

			if (w1 == mw1 && w2 == mw2 && h1 == mh1 && h2 == mh2) {
				f = 1;
			}
		}
		printf("%s\n", f ? "TAK" : "NIE");
	}

	return 0;
}