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 <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <set>
#include <cstring>
#include <list>
#include <iostream>
using namespace std;
#define FOR(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i <= n; i++)
#define FORI(it,n)for(typeof(n.begin()) it = n.begin(); it != n.end(); it++)
#define frs first
#define sec second
#define psh push_back
#define mkp make_pair
typedef long long LL;
typedef long double LD;

const int INF = 2147483647;
const int MAX = 100100;

int n;
int W1[MAX],W2[MAX],H1[MAX],H2[MAX];

bool solve() {
	int w1 = INF,
		 w2 = -1,
		 h1 = INF,
		 h2 = -1;

	scanf("%d", &n);
	FOR(i,n) {
		scanf("%d%d%d%d", &W1[i], &W2[i], &H1[i], &H2[i]);
		w1 = min(w1, W1[i]);
		w2 = max(w2, W2[i]);
		h1 = min(h1, H1[i]);
		h2 = max(h2, H2[i]);
	}
	FOR(i,n) {
		if(W1[i] == w1 && W2[i] == w2 && H1[i] == h1 && H2[i] == h2)
			return true;
	}
	return false;
}

int main() {
	int t;
	scanf("%d", &t);
	while(t--) if(solve())
		printf("TAK\n");
	else
		printf("NIE\n");
}