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
#include <bits/stdc++.h>

using namespace std;

int main(){
		
	int t;
	scanf("%d", &t);
	for(int i=0;i^t;++i){
		int n;
		scanf("%d", &n);
		int minc,maxc,mina=1000001,maxa=0,minb=1000001,maxb=0;
		for (int j=0;j^n;++j)
		{
			int l[n],a[n],b[n];
			
			scanf("%d%d%d", &l[j],&a[j],&b[j]);
			if(a[j]<mina) mina=a[j];
			if(a[j]>maxa) maxa=a[j];
			if(b[j]<minb) minb=b[j];
			if(b[j]>maxb) maxb=b[j];
			
		}
		if(mina>minb){
				
					cout<<"NIE"<<endl;
					
					
			}
		else{
			
			cout<<"TAK"<<endl;
			
			
		}
			 
		
	}
	
	return 0; 

	}