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

using namespace std;

const int MaxN = 100005;

int wmin[MaxN], wmax[MaxN], hmin[MaxN], hmax[MaxN], N;

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d%d%d%d", &wmin[i], &wmax[i], &hmin[i], &hmax[i]);
	}
}

bool find(){
	int w1 = *min_element(wmin, wmin+N),
	    w2 = *max_element(wmax, wmax+N),
	    h1 = *min_element(hmin, hmin+N),
	    h2 = *max_element(hmax, hmax+N);
	
	for(int i = 0; i < N; i++){
		if(wmin[i] == w1 && wmax[i] == w2 && hmin[i] == h1 && hmax[i] == h2){
			return true;
		}
	}
	return false;
}

int main(){
	int t;
	scanf("%d", &t);
	
	while(t--){
		input();
		printf(find() ? "TAK\n" : "NIE\n");
	}
}