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
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include <stdio.h>
#include <algorithm>	
using namespace std;

int main(){
	int t;
	scanf("%d",&t);
	for (int i=0 ; i<t ; i++){
		int n;
		scanf ("%d",&n);
		long int w1[n];
		long int w2[n];
		long int h1[n];
		long int h2[n];
		
		long int x1, x2, y1, y2;
		for (int j=0 ; j<n ; j++){
			scanf ("%ld",&x1);
			scanf ("%ld",&x2);
			scanf ("%ld",&y1);
			scanf ("%ld",&y2);
			w1[j] = x1;
			w2[j] = x2;
			h1[j] = y1;
			h2[j] = y2;
		}
		
		bool isOne = false;
		x1 = w1[0];
		x2 = w2[0];
		y1 = h1[0];
		y2 = h2[0]; 
		for (int j=1 ; j<n ; j++){
			x1 = min(w1[j], x1);
			x2 = max(w2[j], x2);
			y1 = min(h1[j], y1);
			y2 = max(h2[j], y2);	
		}
		for (int j=0 ; j<n ; j++){
			if (x1 == w1[j] && x2 == w2[j] && y1 == h1[j] &&y2 == h2[j]){
				isOne = true;
				break;			
			}	
		} 

		if (isOne) printf("TAK\n");
		else printf("NIE\n");
	}
	return 0;
}