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
#include <cstdio>
#include <vector>
using namespace std;

const int inf = 1000*1000*1000 + 9;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n;
		scanf("%d", &n);
		vector<int> w1(n), w2(n), h1(n), h2(n);
		int minw = inf, maxw = -inf, minh = inf, maxh = -inf;
		for(int i = 0; i < n; ++i)scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
		for(int i = 0; i < n; ++i){
			minw = min(minw, w1[i]);
			minh = min(minh, h1[i]);
			maxw = max(maxw, w2[i]);
			maxh = max(maxh, h2[i]);
		}								//printf("%d %d %d %d", minw, maxw, minh, maxh);
		bool jest = 0;
		for(int i = 0; i < n; ++i){
			if(	minw == w1[i] and
				minh == h1[i] and
				maxw == w2[i] and
				maxh == h2[i]) jest = 1;
		}
		puts(jest ? "TAK" : "NIE");
	}
}