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
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxN=1e6+1;
int n,m,T;
int maxw, minw, maxh, minh;
int h1[maxN], h2[maxN], w1[maxN], w2[maxN]; 
bool choose()
{
	for (int i=1; i<=n; i++)
	  if ((w1[i]==minw) &&(w2[i]==maxw)&& (h1[i]==minh)&& (h2[i]==maxh)) return true;
	return false;
}
int main()
{
	scanf("%d", &T);
	for (int k=1; k<=T; k++)
	{
		scanf("%d", &n);
		maxw=0;minw=1000000000;maxh=0; minh=1000000000;
		for (int i=1; i<=n; i++) 
		{
	
			scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
			minw=min(minw,w1[i]); maxw=max(maxw,w2[i]);
			minh=min(minh,h1[i]); maxh=max(maxh,h2[i]);
		}
		if(choose()) printf("TAK\n");
		else printf("NIE\n");
	}
}