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
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define VI vector<int>
#define PII pair<int,int>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define lint long long int

using namespace std;


int main(){
	int z; scanf("%d",&z);
	while(z--){
		int wmin = 1e9+1,wmax=0;
		int hmin=1e9+1,hmax=0;
		int n; 
		scanf("%d",&n);
		VI w1,w2,h1,h2;
		FOR(i,0,n){
			int a,b,c,d;
			scanf("%d%d%d%d",&a,&b,&c,&d);
			w1.pb(a); w2.pb(b); h1.pb(c); h2.pb(d);
			wmin = min(a,wmin);
			wmax = max(b,wmax);
			hmin = min(c,hmin);
			hmax = max(d,hmax);
		}
		bool dasie = false;
		FOR(i,0,n){
			if(w1[i]==wmin && w2[i]==wmax && h1[i]==hmin && h2[i]==hmax) dasie = true;
		}
		if(dasie) printf("TAK\n");
		else printf("NIE\n");
	}
}