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
//Jakub "Cubix651" Cisło
//Zadanie: Lustra
#include <cstdio>
#include <algorithm>
using namespace std;

bool solve()
{
	int n;
	scanf("%d", &n);
	vector<int> w1(n), w2(n), h1(n), h2(n);
	for(int i = 0; i < n; ++i)
		scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
	int minw = *min_element(w1.begin(), w1.end());
	int maxw = *max_element(w2.begin(), w2.end());
	int minh = *min_element(h1.begin(), h1.end());
	int maxh = *max_element(h2.begin(), h2.end());
	for(int i = 0; i < n; ++i)
		if((w1[i] == minw) && (w2[i] == maxw) && (h1[i] == minh) && (h2[i] == maxh))
			return true;
	return false;
}

int main()
{
	int t;
	scanf("%d", &t);
	while(t--)
		printf(solve()?"TAK\n":"NIE\n");
	return 0;
}