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
49
// lus.cpp : Defines the entry point for the console application.
//
#include <cstdio>
#include <iostream>
#include <climits>
using namespace std;

int main(int argc, char* argv[])
{
	int tc, T;
	
	cin >> T;
	for(tc = 0; tc < T; tc++)
	{
		int N;
		cin>>N;
		int w1min=INT_MAX,w2max=0,h1min=INT_MAX,h2max=0;
		int w1best=INT_MAX,w2best=0,h1best=INT_MAX,h2best=0;
		for(int i=0;i<N;i++)
		{
			int w1,w2,h1,h2;
			cin>>w1>>w2>>h1>>h2;
			if(w1<w1min)
				w1min=w1;
			if(w2>w2max)
				w2max=w2;
			if(h1<h1min)
				h1min=h1;
			if(h2>h2max)
				h2max=h2;
			if(w1<=w1best && w2>=w2best && h1<=h1best && h2>=h2best)
			{
				w1best=w1;
				w2best=w2;
				h1best=h1;
				h2best=h2;
			}
		}
		if(w1min==w1best && w2max==w2best && h1min==h1best && h2max==h2best)
		{
			cout<<"TAK" <<endl;
		}else
		{
			cout<<"NIE"<<endl;		
		}
	}

	return 0;
}