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
#include <iostream>
using namespace std;

const int INFTY = 1000*1000*1000+1;

int max (int *tab, int n) {
	int ret= tab[0];
	for (int i=1; i<n; i++) {
		if (tab[i] > ret) ret= tab[i];
	}
	return ret;
}

bool test () {
	int n;
	cin >> n;
	int a[n], b[n], c[n], d[n];
	for (int i=0; i<n; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]*= -1;
		c[i]*= -1;
	}
	int am= max(a,n), bm= max(b,n), cm= max(c,n), dm=max(d,n);
	for (int i=0; i<n; i++) {
		if (a[i]==am && b[i]==bm && c[i]==cm && d[i]==dm)
			return true;
	}
	return false;
}

int main () {
	int t;
	cin >> t;
	for (int i=0; i<t; i++) {
		cout << (test() ? "TAK\n" : "NIE\n");
	}
	return 0;
}