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

int main() {

	int t=0,n=0;
    int w1,w2,h1,h2,wf1,wf2,hf1,hf2,w1max,w2max,h1max,h2max;


	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
	    wf1=hf1=w1max=h1max=1000000001;
		wf2=hf2=w2max=h2max=-1;

		scanf("%d",&n);
		for(int j=0;j<n;j++)
		{

			scanf("%d %d %d %d",&w1,&w2,&h1,&h2);
			if(w1<w1max)
			w1max=w1;
			if(w2>w2max)
			w2max=w2;
			if(h1<h1max)
			h1max=h1;
			if(h2>h2max)
			h2max=h2;

			if(w1<=wf1&&w2>=wf2&&h1<=hf1&&h2>=hf2)
			{
				wf1=w1;
				wf2=w2;
				hf1=h1;
				hf2=h2;
			}

		}
		if(wf1==w1max&&wf2==w2max&&hf1==h1max&&hf2==h2max)
			printf("%s \n","TAK");
		else
            printf("%s \n","NIE");



	}
	return 0;
}