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
52
53
54
55
56
#include<iostream>
using namespace std;
int t, n;
int a, b, c, d;
int ma, mb, mc, md;
int ka, kb, kc, kd;
bool nk;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>t;
	for(int i=0; i<t; i++){
		cin>>n;
		cin>>ma >>mb >>mc >>md;
		ka=ma;
		kb=mb;
		kc=mc;
		kd=md;
		for(int j=1; j<n; j++){
			nk = false;
			cin>>a >>b >>c >>d;
			if(a < ma){
				nk = true;
				ma = a;
			}
			if(b > mb){
				nk = true;
				mb = b;
			}
			if(c < mc){
				nk = true;
				mc = c;
			}
			if(d > md){
				nk = true;
				md = d;
			}
			
			if(ka > a || kb < b || kc > c || kd < d){
				nk = true;
			}
			
			if(nk){
				ka = a;
				kb = b;
				kc = c;
				kd = d;
			}
		}
		if(ka == ma && kb == mb && kc == mc && kd == md){
			cout<<"TAK" <<endl;
		}else{
			cout<<"NIE" <<endl;
		}
	}
	return 0;
}