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
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
using namespace std;
typedef pair<int,int> PI;
typedef long long LL;
typedef double D;
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define R(I,N) for(int I=0;I<N;I++)
#define F(I,A,B) for(int I=A;I<B;I++)
#define FD(I,N) for(int I=N-1;I>=0;I--)
#define make(A) scanf("%d",&A)
#define MAX 100010
int n,a[MAX][2],b[MAX][2],mi[2],ma[2];
bool test(){
	make(n);
	R(i,2){
		mi[i] = (1e9) + 100;
		ma[i] = 0;
	}
	R(i,n){
		R(j,2){
			scanf("%d%d",&a[i][j],&b[i][j]);
			mi[j] = min(mi[j], a[i][j]);
			ma[j] = max(ma[j], b[i][j]);
		}
	}
	R(i,n){
		bool x = 1;
		R(j,2)if(mi[j] != a[i][j] || ma[j] != b[i][j])x=0;
		if(x)return 1;
	}
	return 0;
}
main(){
	int _;make(_);while(_--)puts(test()?"TAK":"NIE");
}