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

int main() {
	// your code goes here
	int t;
	scanf("%d",&t);
	for(;t>0;t--)
	{
		int n;
		scanf("%d",&n);
		long int h1 = 0;
		long int h2 = 0;
		long int w1  = 0;
		long int w2 = 0;
		if(n>0)
		{
			n--;
			scanf("%ld %ld %ld %ld",&w1,&w2,&h1,&h2);
		}
		bool fortuna = false;
		while(n)
		{
			long int h11 = 0;
			long int h21 = 0;
			long int w21 = 0;
			long int w22 = 0;
			scanf("%ld %ld %ld %ld",&w21,&w22,&h11,&h21);
			if (h11<=h1&&h21>=h2&&w21<=w1&&w22>=w2)
			{
				h1 = h11;
				h2 = h21;
				w1 = w21;
				w2  = w22;
				fortuna=true;
			}
			else if(h11<h1||h21>h2||w21<w1||w22>w2)
			{
				fortuna = false;
			}
			n--;
		}
		if(fortuna) printf("TAK\n");
		else printf("NIE\n");
		
	}
	return 0;
}